runtime: remove write barrier on G in sighandler

sighandler may run during a stop-the-world without a P, so it's not
allowed to have write barriers. Fix the G write to disable the write
barrier (this is safe because the G is reachable from allgs) and mark
the function nowritebarrier.

Change-Id: I907f05d3829e24eeb15fa4d020598af36710e87e
Reviewed-on: https://go-review.googlesource.com/8020
Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
Austin Clements 2015-03-24 11:51:24 -04:00
parent 222f371118
commit 9b0ea6aa27
6 changed files with 18 additions and 6 deletions

View file

@ -32,6 +32,8 @@ func dumpregs(c *sigctxt) {
print("fault ", hex(c.fault()), "\n")
}
// May run during STW, so write barriers are not allowed.
//go:nowritebarrier
func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
_g_ := getg()
c := &sigctxt{info, ctxt}
@ -93,7 +95,7 @@ func sighandler(sig uint32, info *siginfo, ctxt unsafe.Pointer, gp *g) {
}
_g_.m.throwing = 1
_g_.m.caughtsig = gp
setGNoWriteBarrier(&_g_.m.caughtsig, gp)
startpanic()
if sig < uint32(len(sigtable)) {