runtime: don't enable notes (=signals) too early in Plan 9
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>
diff --git a/src/runtime/os_plan9.go b/src/runtime/os_plan9.go
index b534cdb..2bea105 100644
--- a/src/runtime/os_plan9.go
+++ b/src/runtime/os_plan9.go
@@ -293,7 +293,6 @@
ncpu = getproccount()
physPageSize = getPageSize()
getg().m.procid = getpid()
- notify(unsafe.Pointer(funcPC(sigtramp)))
}
//go:nosplit
@@ -311,6 +310,9 @@
}
func initsig(preinit bool) {
+ if !preinit {
+ notify(unsafe.Pointer(funcPC(sigtramp)))
+ }
}
//go:nosplit