[dev.garbage] runtime: Stop running gs during the GCscan phase.

Ensure that all gs are in a scan state when their stacks are being scanned.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/179160044
This commit is contained in:
Rick Hudson 2014-11-21 16:46:27 -05:00
parent 8c3f64022a
commit 273507aa8f
3 changed files with 14 additions and 15 deletions

View file

@ -682,7 +682,12 @@ func newstack() {
gothrow("runtime: g is running but p is not")
}
if gp.preemptscan {
for !castogscanstatus(gp, _Gwaiting, _Gscanwaiting) {
// Likely to be racing with the GC as it sees a _Gwaiting and does the stack scan.
// If so this stack will be scanned twice which does not change correctness.
}
gcphasework(gp)
casfrom_Gscanstatus(gp, _Gscanwaiting, _Gwaiting)
casgstatus(gp, _Gwaiting, _Grunning)
gp.stackguard0 = gp.stack.lo + _StackGuard
gp.preempt = false