Skip to content

Commit 017a542

Browse files
committed
Fix lastcontinuehandler when built as library
When a golang package is built as a c-shared or c-archive for being loaded in a non-go program, it should not crash the program when an exception is observed, but let the main program runtime decide what to do. This fixes this behavior for c-shared/c-archive on Windows Signed-off-by: Simon Ferquel <[email protected]>
1 parent f09a3a5 commit 017a542

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/runtime/signal_windows.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ var testingWER bool
171171
//
172172
//go:nosplit
173173
func lastcontinuehandler(info *exceptionrecord, r *context, gp *g) int32 {
174+
if (islibrary || isarchive) &&
175+
!isgoexception(info, r) {
176+
// go has been loaded in a non-go program.
177+
// if the exception does not originate from go, the go runtime
178+
// should not take responsibility of crashing the process
179+
return _EXCEPTION_CONTINUE_SEARCH
180+
}
174181
if testingWER {
175182
return _EXCEPTION_CONTINUE_SEARCH
176183
}

0 commit comments

Comments
 (0)