From: Elias Naur Date: Fri, 11 Aug 2017 17:46:45 +0000 (+0200) Subject: runtime: fix crashing with foreign signal handlers on Darwin X-Git-Tag: go1.10beta1~1635 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=057a34a281a52b474184614ac63b808974e22549;p=gostls13.git 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 Reviewed-by: Ian Lance Taylor --- diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index e087e145aa..a6385a0a5e 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -398,6 +398,9 @@ func dieFromSignal(sig uint32) { // First, try any signal handler installed before the runtime // initialized. fn := atomic.Loaduintptr(&fwdSig[sig]) + // On Darwin, sigtramp is called even for non-Go signal handlers. + // Mark the signal as unhandled to ensure it is forwarded. + atomic.Store(&handlingSig[sig], 0) setsig(sig, fn) raise(sig)