diff options
author | Cherry Mui <cherryyz@google.com> | 2024-04-26 21:47:19 -0400 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2024-05-06 21:13:43 +0000 |
commit | be003bd00b14fa29cd0876fb4fab627a007e2bbf (patch) | |
tree | 95f9724a3df6e274384842cc23f2c128e4c434db /src/runtime | |
parent | be29a02161eae9aa7519496e3d058b3214f91508 (diff) | |
download | go-be003bd00b14fa29cd0876fb4fab627a007e2bbf.tar.gz go-be003bd00b14fa29cd0876fb4fab627a007e2bbf.zip |
runtime: don't re-raise ignored signal
If a signal lands on a non-Go thread, and Go code doesn't want to
handle it, currently we re-raise the signal in the signal handler
after uninstalling our handler, so the C code can handle it.
But if there is no C signal handler and the signal is ignored,
there is no need to re-raise the signal. Just ignore it. This
avoids uninstalling and reinstalling our handler, which, for some
reason, changes errno when TSAN is used. And TSAN does not like
errno being changed in the signal handler.
Not really sure if this is the bset of complete fix, but it does
fix the immediate problem, and it seems a reasonable thing to do
by itself.
Test case is CL 581722.
Fixes #66427.
Change-Id: I7a043d53059f1ff4080f4fc8ef4065d76ee7d78a
Reviewed-on: https://go-review.googlesource.com/c/go/+/582077
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime')
-rw-r--r-- | src/runtime/signal_unix.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 6ca87561e8..f115980c34 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -953,10 +953,17 @@ func raisebadsignal(sig uint32, c *sigctxt) { } var handler uintptr + var flags int32 if sig >= _NSIG { handler = _SIG_DFL } else { handler = atomic.Loaduintptr(&fwdSig[sig]) + flags = sigtable[sig].flags + } + + // If the signal is ignored, raising the signal is no-op. + if handler == _SIG_IGN || (handler == _SIG_DFL && flags&_SigIgn != 0) { + return } // Reset the signal handler and raise the signal. |