New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
runtime: On Windows, lastcontinuehandler intercepts exception raised in non-go code #32648
Comments
/cc @ianlancetaylor |
Thank you for raising this issue @simonferquel Unfortunately I still don't see what your problem is. Can you, please, provide all steps I need to reproduce it. Including all source code and tools I need. Thank you. Alex |
@alexbrainman sure, no problem. I'll setup a github repo with a repro, and a quick video highlighting the issue. Thanks for taking the time to investigate this with me, this could open the door to better cross-language interop and debugging experience. |
Here is the repro: https://github.com/simonferquel/golang-continue-handler-repro If you want to run the example, you'll need:
VS code tasks are setup, so that hitting |
I can see the problem, thank you very much. You are using Go dll, not Go executable. This is very different - C# runtime should be in control of what happens inside of C# process, not Go runtime. I will comment on https://go-review.googlesource.com/c/go/+/181839 about what to do next. Alex |
Hmm that makes perfect sense. How can I determine that I am running a dll? Some global var in runtime? |
got it: Line 936 in 8f296f5
|
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 fix golang#32648 Signed-off-by: Simon Ferquel <simon.ferquel@docker.com>
If you use x86 , that will be good! |
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 golang#32648.
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 golang#32648.
Change https://golang.org/cl/181839 mentions this issue: |
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 golang#32648. Change-Id: Ia455e69b8dde2a6f42f06b90e8af4aa322ca269a GitHub-Last-Rev: dbdffcb GitHub-Pull-Request: golang#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>
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 golang#32648. Change-Id: Ia455e69b8dde2a6f42f06b90e8af4aa322ca269a GitHub-Last-Rev: dbdffcb GitHub-Pull-Request: golang#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>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I have built a GO program that calls C# code using CGO. When the .Net debugger is attached to the process, when any .net code is called, I get a panic like with the following trace:
When using .Net core instead of the full .Net framework, the same problem occurs as soon as a breakpoint is hit in C# code.
I can also reproduce the error by attaching Visual C++ debugger and using CGO to call C code calling DebugBreak
What did you expect to see?
Using another language debugger on a GO program to break on code called using CGO should work without crashing the go runtime.
What did you see instead?
Using another language debugger on a GO program (to debug non-go code called using CGO), crashes my program any time an exception of type EXCEPTION_BREAKPOINT is raised.
Candidate fix
This behavior is fixed in #32574, although it might have undesired side effects I am not aware of.
The text was updated successfully, but these errors were encountered: