diff options
| author | David Chase <drchase@google.com> | 2023-08-14 13:20:45 -0400 |
|---|---|---|
| committer | David Chase <drchase@google.com> | 2023-08-16 17:51:47 +0000 |
| commit | 91bea5a21dc1a951a7fbe491a6da07b664c5a167 (patch) | |
| tree | 8ea335dd8c0e4e75ba99b8786bf1ad8c507c368a /src | |
| parent | 0e9bf41e1dce5c75f80f255cc11b8076b6203994 (diff) | |
| download | go-91bea5a21dc1a951a7fbe491a6da07b664c5a167.tar.xz | |
runtime: guard against runtime/sema* ops on Darwin signal stack.
These operations misbehave and cause hangs and flakes.
Fail hard if they are attempted.
Tested by backing out the Darwin-profiling-hang fix
CL 518836 and running run.bash, the guard panicked in
runtime/pprof tests, as expected/hoped.
Updates #61768
Change-Id: I89b6f85745fbaa2245141ea98f584afc5d6b133e
Reviewed-on: https://go-review.googlesource.com/c/go/+/519275
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src')
| -rw-r--r-- | src/runtime/os_darwin.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/runtime/os_darwin.go b/src/runtime/os_darwin.go index 105de47a1f..be29095329 100644 --- a/src/runtime/os_darwin.go +++ b/src/runtime/os_darwin.go @@ -41,7 +41,12 @@ func semasleep(ns int64) int32 { if ns >= 0 { start = nanotime() } - mp := getg().m + g := getg() + mp := g.m + if g == mp.gsignal { + // sema sleep/wakeup are implemented with pthreads, which are not async-signal-safe on Darwin. + throw("semasleep on Darwin signal stack") + } pthread_mutex_lock(&mp.mutex) for { if mp.count > 0 { @@ -70,6 +75,9 @@ func semasleep(ns int64) int32 { //go:nosplit func semawakeup(mp *m) { + if g := getg(); g == g.m.gsignal { + throw("semawakeup on Darwin signal stack") + } pthread_mutex_lock(&mp.mutex) mp.count++ if mp.count > 0 { |
