-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: core not dumped for crash from cgo #6988
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
Labels
Milestone
Comments
I did set the env variable and ulimit -c unlimited. See the bug report just below the line that said "command line", reproduced here: ulimit -c unlimited; GOTRACEBACK=crash go run crash-cgo.go I expected to get the core dump, but I still only get the traceback. Some context leading to my filing this issue here: https://groups.google.com/d/msg/golang-nuts/VB_9P29X040/56MEtpKu0QgJ |
this is working as intended on darwin/amd64 (see comment in signal_unix.c). For linux, this is because somehow the SIGABRT signal is blocked in the cgo thread. for example, this patch could fix the problem on linux (only): diff -r acad7f360212 src/pkg/runtime/signal_unix.c --- a/src/pkg/runtime/signal_unix.c Thu Dec 19 21:37:44 2013 +0100 +++ b/src/pkg/runtime/signal_unix.c Thu Dec 19 16:19:16 2013 -0500 @@ -112,7 +112,10 @@ if(sizeof(void*) == 8) return; #endif + Sigset zero; + runtime·memclr((byte *)&zero, sizeof zero); + runtime·rtsigprocmask(SIG_SETMASK, &zero, &old, sizeof old); runtime·setsig(SIGABRT, SIG_DFL, false); runtime·raise(SIGABRT); } |
Thanks, when you put it that way the problem is obvious: the call to sigaction in runtime·setsig sets the signal mask to block all signals while executing the signal handler. Calling runtime·setsig again does not change the fact that the code is executing inside a signal handler and the SIGABRT signal is blocked. It would be received when the signal handler returns and signals are unblocked, but of course the code instead simply exits before that happens. |
I think explicit unblocking would be mildly preferable, because easier to understand. Interestingly I have this code in the gccgo runtime for any signal that may cause a panic. /* The signal handler blocked signals; unblock them. */ i = sigfillset (&clear); __go_assert (i == 0); i = pthread_sigmask (SIG_UNBLOCK, &clear, NULL); __go_assert (i == 0); |
OK, then I will first do some code refactoring because the current sigprocmask functions have different prototypes (and even names) on different Unixes. Owner changed to @minux. Status changed to Started. |
This issue was closed by revision 0097d30. Status changed to Fixed. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The text was updated successfully, but these errors were encountered: