aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/runtime/proc.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2020-11-07 07:25:23 -0800
committerIan Lance Taylor <iant@golang.org>2020-11-10 07:25:32 -0800
commitcf392dbdf17e38026f8e3c0e9af7f5b87f63be56 (patch)
tree6b1df9cdc36cc47b6164db69a14bc86a63dc77c6 /libgo/go/runtime/proc.go
parent0000ea4fb4eaacbd2c954d78d7f8e9f03c7be739 (diff)
downloadgcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.zip
gcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.tar.gz
gcc-cf392dbdf17e38026f8e3c0e9af7f5b87f63be56.tar.bz2
libgo: update to Go 1.15.4 release
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/268177
Diffstat (limited to 'libgo/go/runtime/proc.go')
-rw-r--r--libgo/go/runtime/proc.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go
index 84070e4..0ca6c02 100644
--- a/libgo/go/runtime/proc.go
+++ b/libgo/go/runtime/proc.go
@@ -1258,6 +1258,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.
@@ -3349,11 +3357,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.