-
Notifications
You must be signed in to change notification settings - Fork 18k
runtime: add a way to generate core dumps when a panic is going to kill the process #4959
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
At least on traditional Unix systems the only way to get a core dump is via a signal. I don't know of any other way even on new systems. I think that means that we need a runtime function for this, to reset the signal handler for some core-dumping signal (e.g., SIGABRT) to the default, and then to send that signal to the process. Alternatively, we could avoid installing a signal handler for SIGABRT, and leave it available to generate a core dump. I think it's unusual for a program to want to handle SIGABRT in any other way. |
Some people are used to get the stack traces with SIGABRT (C-\), some people are used to SIGQUIT, iirc. I personally use C-\ always. A runtime.Crash() would be great, but I'd like also a signal. What's the use of SIGTRAP, outside a debugger? Maybe it fits? Then runtime.Breakpoint() could be used for that too. |
when a program panics, it's often in a inconsistent state, so relying on Go code to handle core dump is not reliable. Thus, perhaps we could introduce this to runtime/debug package. // after calling CoreDumpWhenPanic(), if a panic is not recovered, the program will // dump core (if the OS allows) after outputting normal crash stack traces to stderr. func CoreDumpWhenPanic() to enable the core dump on panic behavior. |
now i think that instead of introducing a new non-portable API (as no concept of coredump exists on windows), we might well just define a new environment variable, GOCOREDUMP=1, or something like that), we don't need to document it and it remains purely as a undocumented debugging trick (like GOTRACEBACK and GOGCTRACE). What do you think about this proposal? |
Random other thoughts: We enable GOGCTRACE for our services. Very useful to understand why production code is pausing. No need to leave these goodies completely undocumented. :-) ulimit -c is typically 0 on Fedora and you have to set it to something bigger to get core dumps from C services. It would be nice if this thing works the same. Might be worth reading through here a bit: http://fedoraproject.org/wiki/StackTraces#Daemons_and_their_spawn Making it work like C services means this kind of stuff keeps working: http://www.freedesktop.org/software/systemd/man/systemd-coredumpctl.html |
More about how systemd's thing work: http://stackoverflow.com/questions/2065912/core-dumped-but-core-file-is-not-in-current-directory /proc/sys/kernel/core_pattern can take a | which means to run a command. |
Status changed to Duplicate. Merged into issue #3257. |
This issue was closed.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
by viriketo:
The text was updated successfully, but these errors were encountered: