]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't test sig.inuse in sigsend
authorIan Lance Taylor <iant@golang.org>
Wed, 21 Apr 2021 00:02:37 +0000 (17:02 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 21 Apr 2021 02:39:25 +0000 (02:39 +0000)
Signals can be delivered on a different thread. There is no necessary
happens-before relationship between setting sig.inuse in signal_enable
and checking it in sigsend. It is theoretically possible, if unlikely,
that sig.inuse is set by thread 1, thread 2 receives a signal, does not
see that sig.inuse is set, and discards the signal. This could happen
if the signal is received immediately after the first call to signal_enable.

For #33174

Change-Id: Idb0f1c77847b7d4d418bd139e801c0c4460531d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/312131
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/runtime/sigqueue.go

index a282c7aca77b89f62fc7504e2dd0511af2f93d69..aae1d00046175bcd8978191553bd9d983167ab4a 100644 (file)
@@ -72,7 +72,7 @@ const (
 // It runs from the signal handler, so it's limited in what it can do.
 func sigsend(s uint32) bool {
        bit := uint32(1) << uint(s&31)
-       if !sig.inuse || s >= uint32(32*len(sig.wanted)) {
+       if s >= uint32(32*len(sig.wanted)) {
                return false
        }