mirror of
https://github.com/golang/go.git
synced 2025-05-23 08:21:24 +00:00
If Go DLL is used by external C program, and lastcontinuehandler is reached, lastcontinuehandler will crash the process it is running in. But it should not be up to Go runtime to decide if process to be crashed or not - it should be up to C runtime. This CL adjusts lastcontinuehandler to not to crash when running as DLL. Fixes #32648. Change-Id: Ia455e69b8dde2a6f42f06b90e8af4aa322ca269a GitHub-Last-Rev: dbdffcb43206e94ef130ecadd1c82a8763225ac2 GitHub-Pull-Request: golang/go#32574 Reviewed-on: https://go-review.googlesource.com/c/go/+/181839 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
29 lines
893 B
Go
29 lines
893 B
Go
// +build windows,cgo
|
|
|
|
package main
|
|
|
|
// #include <windows.h>
|
|
// typedef void(*callmeBackFunc)();
|
|
// static void bridgeCallback(callmeBackFunc callback) {
|
|
// callback();
|
|
//}
|
|
import "C"
|
|
|
|
// CallMeBack call backs C code.
|
|
//export CallMeBack
|
|
func CallMeBack(callback C.callmeBackFunc) {
|
|
C.bridgeCallback(callback)
|
|
}
|
|
|
|
// Dummy is called by the C code before registering the exception/continue handlers simulating a debugger.
|
|
// This makes sure that the Go runtime's lastcontinuehandler is reached before the C continue handler and thus,
|
|
// validate that it does not crash the program before another handler could take an action.
|
|
// The idea here is to reproduce what happens when you attach a debugger to a running program.
|
|
// It also simulate the behavior of the .Net debugger, which register its exception/continue handlers lazily.
|
|
//export Dummy
|
|
func Dummy() int {
|
|
return 42
|
|
}
|
|
|
|
func main() {}
|