From 78992411ded8288ed32790ece2b998f0a6c7d997 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Fri, 15 Apr 2022 13:46:00 -0700 Subject: [release-branch.go1.17] runtime: don't block preemption signal in new M's or ensureSigM No test because we already have a test in the syscall package. The issue reports 1 failure per 100,000 iterations, which is rare enough that our builders won't catch the problem. For #52226 Fixes #52374 Change-Id: I17633ff6cf676b6d575356186dce42cdacad0746 Reviewed-on: https://go-review.googlesource.com/c/go/+/400315 Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Michael Knyszek Reviewed-by: Ian Lance Taylor (cherry picked from commit e3982660a73b04a87c08215cb5aaa16d816ea573) Reviewed-on: https://go-review.googlesource.com/c/go/+/400317 Reviewed-by: Austin Clements --- src/runtime/signal_unix.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 6096760b50c..33c3f2ee657 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -1151,6 +1151,7 @@ func unminitSignals() { // blockableSig reports whether sig may be blocked by the signal mask. // We never want to block the signals marked _SigUnblock; // these are the synchronous signals that turn into a Go panic. +// We never want to block the preemption signal if it is being used. // In a Go program--not a c-archive/c-shared--we never want to block // the signals marked _SigKill or _SigThrow, as otherwise it's possible // for all running threads to block them and delay their delivery until @@ -1161,6 +1162,9 @@ func blockableSig(sig uint32) bool { if flags&_SigUnblock != 0 { return false } + if sig == sigPreempt && preemptMSupported && debug.asyncpreemptoff == 0 { + return false + } if isarchive || islibrary { return true } -- cgit v1.2.3-54-g00ecf