]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: don't enable notes (=signals) too early in Plan 9
authorRichard Miller <miller.research@gmail.com>
Mon, 18 May 2020 08:34:17 +0000 (09:34 +0100)
committerDavid du Colombier <0intro@gmail.com>
Mon, 18 May 2020 09:13:38 +0000 (09:13 +0000)
The Plan 9 runtime startup was enabling notes (like Unix signals)
before the gsignal stack was allocated. This left a small window
of time where an interrupt (eg by the parent killing a subprocess
quickly after exec) would cause a null pointer dereference in
sigtramp. This would leave the interrupted process suspended in
'broken' state instead of exiting. We've observed this on the
builders, where it can make a test time out waiting for the broken
process to terminate.

Updates #38772

Change-Id: I54584069fd3109595f06c78724c1f6419e028aab
Reviewed-on: https://go-review.googlesource.com/c/go/+/234397
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
src/runtime/os_plan9.go

index b534cdba5d35442ac35f4c0e1583b3b6c69ace46..2bea1058f2d86ce5b4e20eb916bd57723664e70a 100644 (file)
@@ -293,7 +293,6 @@ func osinit() {
        ncpu = getproccount()
        physPageSize = getPageSize()
        getg().m.procid = getpid()
-       notify(unsafe.Pointer(funcPC(sigtramp)))
 }
 
 //go:nosplit
@@ -311,6 +310,9 @@ func goenvs() {
 }
 
 func initsig(preinit bool) {
+       if !preinit {
+               notify(unsafe.Pointer(funcPC(sigtramp)))
+       }
 }
 
 //go:nosplit