aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/signal_unix.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-04-18 20:11:46 -0700
committerIan Lance Taylor <iant@golang.org>2020-04-22 00:01:14 +0000
commite5bd6e1c7944713c816cf94ae412a700c271cfca (patch)
tree2fd972e8b6e0e72379e5a6adc626e034416efa9d /src/runtime/signal_unix.go
parent5a75f7c0b0789fe04ea4879a524cc95dbe734636 (diff)
downloadgo-e5bd6e1c7944713c816cf94ae412a700c271cfca.tar.gz
go-e5bd6e1c7944713c816cf94ae412a700c271cfca.zip
runtime: crash on SI_USER SigPanic signal
Clean up the code a little bit to make it clearer: Don't check throwsplit for a SI_USER signal. If throwsplit is set for a SigPanic signal, always throw; discard any other flags. Fixes #36420 Change-Id: Ic9dcd1108603d241f71c040504dfdc6e528f9767 Reviewed-on: https://go-review.googlesource.com/c/go/+/228900 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
Diffstat (limited to 'src/runtime/signal_unix.go')
-rw-r--r--src/runtime/signal_unix.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go
index c33f88b046..f5d79e561c 100644
--- a/src/runtime/signal_unix.go
+++ b/src/runtime/signal_unix.go
@@ -546,10 +546,10 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
if sig < uint32(len(sigtable)) {
flags = sigtable[sig].flags
}
- if flags&_SigPanic != 0 && gp.throwsplit {
+ if c.sigcode() != _SI_USER && flags&_SigPanic != 0 && gp.throwsplit {
// We can't safely sigpanic because it may grow the
// stack. Abort in the signal handler instead.
- flags = (flags &^ _SigPanic) | _SigThrow
+ flags = _SigThrow
}
if isAbortPC(c.sigpc()) {
// On many architectures, the abort function just
@@ -588,7 +588,11 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
dieFromSignal(sig)
}
- if flags&_SigThrow == 0 {
+ // _SigThrow means that we should exit now.
+ // If we get here with _SigPanic, it means that the signal
+ // was sent to us by a program (c.sigcode() == _SI_USER);
+ // in that case, if we didn't handle it in sigsend, we exit now.
+ if flags&(_SigThrow|_SigPanic) == 0 {
return
}