From 27aed3ce6898f3078f4ee52935c63a12aca86b9e Mon Sep 17 00:00:00 2001 From: Rick Hudson Date: Thu, 29 Jan 2015 10:37:32 -0500 Subject: [PATCH] runtime: scanvalid race Fixes #9727 Set gcscanvalid=false after you have cased to _Grunning. If you do it before the cas and the atomicstatus races to a scan state, the scan will set gcscanvalid=true and we will be _Grunning with gcscanvalid==true which is not a good thing. Change-Id: Ie53ea744a5600392b47da91159d985fe6fe75961 Reviewed-on: https://go-review.googlesource.com/3510 Reviewed-by: Austin Clements --- src/runtime/proc1.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/runtime/proc1.go b/src/runtime/proc1.go index 8efb5467be..82fc41d5b3 100644 --- a/src/runtime/proc1.go +++ b/src/runtime/proc1.go @@ -387,10 +387,6 @@ func casgstatus(gp *g, oldval, newval uint32) { }) } - if newval == _Grunning { - gp.gcscanvalid = false - } - // loop if gp->atomicstatus is in a scan state giving // GC time to finish and change the state to oldval. for !cas(&gp.atomicstatus, oldval, newval) { @@ -407,6 +403,9 @@ func casgstatus(gp *g, oldval, newval uint32) { // }) // } } + if newval == _Grunning { + gp.gcscanvalid = false + } } // casgstatus(gp, oldstatus, Gcopystack), assuming oldstatus is Gwaiting or Grunnable. -- 2.51.0