aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2017-06-12 23:14:05 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2017-06-12 23:14:05 +0000
commita282a875c8856b024b51b8c643d080a6ea2dd8ab (patch)
treed3dcd53208e91dad347a36dceeff7ac3d626c251
parentb51483f48f3cc67cf4b508bdd9c4b6a47b44c53a (diff)
downloadgcc-a282a875c8856b024b51b8c643d080a6ea2dd8ab.zip
gcc-a282a875c8856b024b51b8c643d080a6ea2dd8ab.tar.gz
gcc-a282a875c8856b024b51b8c643d080a6ea2dd8ab.tar.bz2
runtime: ignore _Gscan bit when checking status in CgocallDone
Also always access the atomicstatus field atomically. The effect of not checking the _Gscan bit is that if the GC decides to scan the stack just as the goroutine is leaving the system call, the goroutine might fail to call exitsyscall. Then then typically causes a runtime assertion failure later on. If we do call exitsyscall as we should, it will stall (in casgstatus) until the _Gscan bit is cleared. No separate test. I've observed causing sporadic failures running the misc/cgo tests, but we don't currently have a way to run those routinely for gccgo. I should fix that. Reviewed-on: https://go-review.googlesource.com/45392 From-SVN: r249138
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--libgo/go/runtime/cgo_gccgo.go2
-rw-r--r--libgo/go/runtime/proc.go2
3 files changed, 3 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index aebab77..d4a3129 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-61222d34c1b33a369bd86008a0541455dd17727e
+908fc7e46ebe36658ed86b65a3d165fccb2e8576
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/libgo/go/runtime/cgo_gccgo.go b/libgo/go/runtime/cgo_gccgo.go
index a55fb43..b0ad2f1 100644
--- a/libgo/go/runtime/cgo_gccgo.go
+++ b/libgo/go/runtime/cgo_gccgo.go
@@ -54,7 +54,7 @@ func CgocallDone() {
// If we are invoked because the C function called _cgo_panic,
// then _cgo_panic will already have exited syscall mode.
- if gp.atomicstatus == _Gsyscall {
+ if readgstatus(gp)&^_Gscan == _Gsyscall {
exitsyscall(0)
}
diff --git a/libgo/go/runtime/proc.go b/libgo/go/runtime/proc.go
index 64735e2..038f20e 100644
--- a/libgo/go/runtime/proc.go
+++ b/libgo/go/runtime/proc.go
@@ -1459,7 +1459,7 @@ func dropm() {
// gccgo sets the stack to Gdead here, because the splitstack
// context is not initialized.
- mp.curg.atomicstatus = _Gdead
+ atomic.Store(&mp.curg.atomicstatus, _Gdead)
mp.curg.gcstack = nil
mp.curg.gcnextsp = nil