Skip to content

Commit 057a34a

Browse files
author
Elias Naur
committed
runtime: fix crashing with foreign signal handlers on Darwin
The dieFromSignal runtime function attempts to forward crashing signals to a signal handler registered before the runtime was initialized, if any. However, on Darwin, a special signal handler trampoline is invoked, even for non-Go signal handlers. Clear the crashing signal's handlingSig entry to ensure sigtramp forwards the signal. Fixes the darwin/386 builder. Updates #20392 Updates #19389 Change-Id: I441a3d30c672cdb21ed6d8f1e1322d7c0e5b9669 Reviewed-on: https://go-review.googlesource.com/55032 Run-TryBot: Elias Naur <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 51ba2bb commit 057a34a

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/runtime/signal_unix.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,9 @@ func dieFromSignal(sig uint32) {
398398
// First, try any signal handler installed before the runtime
399399
// initialized.
400400
fn := atomic.Loaduintptr(&fwdSig[sig])
401+
// On Darwin, sigtramp is called even for non-Go signal handlers.
402+
// Mark the signal as unhandled to ensure it is forwarded.
403+
atomic.Store(&handlingSig[sig], 0)
401404
setsig(sig, fn)
402405
raise(sig)
403406

0 commit comments

Comments
 (0)