]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: remove write barrier on G in sighandler
authorAustin Clements <austin@google.com>
Tue, 24 Mar 2015 15:51:24 +0000 (11:51 -0400)
committerAustin Clements <austin@google.com>
Thu, 26 Mar 2015 15:26:29 +0000 (15:26 +0000)
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>
src/runtime/os3_plan9.go
src/runtime/signal_386.go
src/runtime/signal_amd64x.go
src/runtime/signal_arm.go
src/runtime/signal_arm64.go
src/runtime/signal_ppc64x.go

index 27519debd355b5d352adf4d780a3a0d809ef3245..fa49ad681f3882e0fc3019dec28abd131537751f 100644 (file)
@@ -6,6 +6,8 @@ package runtime
 
 import "unsafe"
 
+// May run during STW, so write barriers are not allowed.
+//go:nowritebarrier
 func sighandler(_ureg *ureg, note *byte, gp *g) int {
        _g_ := getg()
        var t sigTabT
@@ -79,7 +81,7 @@ func sighandler(_ureg *ureg, note *byte, gp *g) int {
        }
 Throw:
        _g_.m.throwing = 1
-       _g_.m.caughtsig = gp
+       setGNoWriteBarrier(&_g_.m.caughtsig, gp)
        startpanic()
        print(notestr, "\n")
        print("PC=", hex(c.pc()), "\n")
index 0ca593de029a16587884ac2c96656139516d7013..b63299511f6865423a3423d03910ed94b5277c60 100644 (file)
@@ -24,6 +24,8 @@ func dumpregs(c *sigctxt) {
        print("gs     ", hex(c.gs()), "\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}
@@ -98,7 +100,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)) {
index cd87d76a50a2e093440fc4cc6c21fb84f3865eb3..5dc9d8070a83693e26d48c337828111d4bba8ff8 100644 (file)
@@ -37,6 +37,8 @@ func dumpregs(c *sigctxt) {
 
 var crashing int32
 
+// 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}
@@ -134,7 +136,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)
 
        if crashing == 0 {
                startpanic()
index c07b45ef18cb6898f54b75e9898f10ba9197c5a6..7d417fa2b3c537fadaf0622b154fa522d0d03f1e 100644 (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)) {
index cc8985872cab99279b879bb9982a5823cd0f6d5c..efb84029e28b2c5a76c35eb068db2890857145df 100644 (file)
@@ -45,6 +45,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}
@@ -106,7 +108,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)) {
index 94b4708dd598bf00b778ea7514be564e772c730a..018d7d62efa19aa00e0d8d84ce41266162e71d8a 100644 (file)
@@ -50,6 +50,8 @@ func dumpregs(c *sigctxt) {
        print("trap ", hex(c.trap()), "\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}
@@ -111,7 +113,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)) {