aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorFilippo Valsorda <filippo@golang.org>2020-11-13 03:04:52 +0100
committerFilippo Valsorda <filippo@golang.org>2020-11-13 03:04:52 +0100
commit11087322f85d5ace6494fc194982d92f0a34df0f (patch)
tree1fc71e2b2e13647ad4a2a86f95794b47ca950e99 /src/runtime/proc.go
parented9dc25d693c02aeeb8ed084b28b6d7f9489dc5a (diff)
parentc53315d6cf1b4bfea6ff356b4a1524778c683bb9 (diff)
downloadgo-11087322f85d5ace6494fc194982d92f0a34df0f.tar.gz
go-11087322f85d5ace6494fc194982d92f0a34df0f.zip
[dev.boringcrypto.go1.15] all: merge go1.15.5 into dev.boringcrypto.go1.15
Change-Id: I075fd29b5d035cac905c7bc3145405bf622a981b
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index 035822216d..2f1272d310 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -1281,6 +1281,14 @@ found:
checkdead()
unlock(&sched.lock)
+ if GOOS == "darwin" {
+ // Make sure pendingPreemptSignals is correct when an M exits.
+ // For #41702.
+ if atomic.Load(&m.signalPending) != 0 {
+ atomic.Xadd(&pendingPreemptSignals, -1)
+ }
+ }
+
if osStack {
// Return from mstart and let the system thread
// library free the g0 stack and terminate the thread.
@@ -3475,11 +3483,24 @@ func syscall_runtime_AfterForkInChild() {
inForkedChild = false
}
+// pendingPreemptSignals is the number of preemption signals
+// that have been sent but not received. This is only used on Darwin.
+// For #41702.
+var pendingPreemptSignals uint32
+
// Called from syscall package before Exec.
//go:linkname syscall_runtime_BeforeExec syscall.runtime_BeforeExec
func syscall_runtime_BeforeExec() {
// Prevent thread creation during exec.
execLock.lock()
+
+ // On Darwin, wait for all pending preemption signals to
+ // be received. See issue #41702.
+ if GOOS == "darwin" {
+ for int32(atomic.Load(&pendingPreemptSignals)) > 0 {
+ osyield()
+ }
+ }
}
// Called from syscall package after Exec.