From 3c60e6e8cfc6da21fc12aadaff63d780310ba822 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 16 Jun 2015 19:20:18 -0400 Subject: runtime: fix races in stack scan This fixes a hang during runtime.TestTraceStress. It also fixes double-scan of stacks, which leads to stack barrier installation failures. Both of these have shown up as flaky failures on the dashboard. Fixes #10941. Change-Id: Ia2a5991ce2c9f43ba06ae1c7032f7c898dc990e0 Reviewed-on: https://go-review.googlesource.com/11089 Reviewed-by: Austin Clements --- src/runtime/stack1.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/runtime/stack1.go') diff --git a/src/runtime/stack1.go b/src/runtime/stack1.go index cb2110efb6..c5ffb0e130 100644 --- a/src/runtime/stack1.go +++ b/src/runtime/stack1.go @@ -756,13 +756,16 @@ func newstack() { // be set and gcphasework will simply // return. } - gcphasework(gp) + if !gp.gcscandone { + scanstack(gp) + gp.gcscandone = true + } + gp.preemptscan = false + gp.preempt = false casfrom_Gscanstatus(gp, _Gscanwaiting, _Gwaiting) casgstatus(gp, _Gwaiting, _Grunning) gp.stackguard0 = gp.stack.lo + _StackGuard - gp.preempt = false - gp.preemptscan = false // Tells the GC premption was successful. - gogo(&gp.sched) // never return + gogo(&gp.sched) // never return } // Act like goroutine called runtime.Gosched. -- cgit v1.3-5-g9baa