From c33ced6d8a2bb4db6896ff36cfcaac2bbdf123d1 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 20 Apr 2021 17:02:37 -0700 Subject: [PATCH] runtime: don't test sig.inuse in sigsend 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 Run-TryBot: Ian Lance Taylor TryBot-Result: Go Bot Reviewed-by: Bryan C. Mills --- src/runtime/sigqueue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/sigqueue.go b/src/runtime/sigqueue.go index a282c7aca7..aae1d00046 100644 --- a/src/runtime/sigqueue.go +++ b/src/runtime/sigqueue.go @@ -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 } -- 2.48.1