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>
This commit is contained in:
Richard Miller 2020-05-18 09:34:17 +01:00 committed by David du Colombier
parent 2b70ffe930
commit bb59a1360a
1 changed files with 3 additions and 1 deletions

View 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