mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
runtime: when dying from a signal use the previous signal handler
Before this CL, whenever the Go runtime wanted to kill its own process with a signal dieFromSignal would reset the signal handler to _SIG_DFL. Unfortunately, if any signal handler were installed before the Go runtime initialized, it wouldn't be invoked either. Instead, use whatever signal handler was installed before initialization. The motivating use case is Crashlytics on Android. Before this CL, Crashlytics would not consider a crash from a panic() since the corresponding SIGABRT never reached its signal handler. Updates #11382 Updates #20392 (perhaps even fixes it) Fixes #19389 Change-Id: I0c8633329433b45cbb3b16571bea227e38e8be2e Reviewed-on: https://go-review.googlesource.com/49590 Run-TryBot: Elias Naur <elias.naur@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
7d80a2ea18
commit
5500c9ce27
3 changed files with 79 additions and 1 deletions
|
|
@ -394,8 +394,11 @@ func sigpanic() {
|
|||
//go:nosplit
|
||||
//go:nowritebarrierrec
|
||||
func dieFromSignal(sig uint32) {
|
||||
setsig(sig, _SIG_DFL)
|
||||
unblocksig(sig)
|
||||
// First, try any signal handler installed before the runtime
|
||||
// initialized.
|
||||
fn := atomic.Loaduintptr(&fwdSig[sig])
|
||||
setsig(sig, fn)
|
||||
raise(sig)
|
||||
|
||||
// That should have killed us. On some systems, though, raise
|
||||
|
|
@ -407,6 +410,14 @@ func dieFromSignal(sig uint32) {
|
|||
osyield()
|
||||
osyield()
|
||||
|
||||
// If that didn't work, try _SIG_DFL.
|
||||
setsig(sig, _SIG_DFL)
|
||||
raise(sig)
|
||||
|
||||
osyield()
|
||||
osyield()
|
||||
osyield()
|
||||
|
||||
// If we are still somehow running, just exit with the wrong status.
|
||||
exit(2)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue