]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: keep gcMarkRootCheck happy with spare Gs
authorAustin Clements <austin@google.com>
Mon, 17 Oct 2016 01:22:02 +0000 (21:22 -0400)
committerAustin Clements <austin@google.com>
Wed, 19 Oct 2016 21:36:53 +0000 (21:36 +0000)
oneNewExtraM creates a spare M and G for use with cgo callbacks. The G
doesn't run right away, but goes directly into syscall status. For the
garbage collector, it's marked as "scan valid" and not on the rescan
list, but I forgot to also mark it as "scan done". As a result,
gcMarkRootCheck thinks that the goroutine hasn't been scanned and
panics.

This only affects GODEBUG=gccheckmark=1 mode, since we otherwise skip
the gcMarkRootCheck.

Fixes #17473.

Change-Id: I94f5671c42eb44bd5ea7dc68fbf85f0c19e2e52c
Reviewed-on: https://go-review.googlesource.com/31139
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
src/runtime/proc.go

index 937135961aaa91da979044f4fda150a2d4314d12..f68a189997c0c1aa14a6b4638620ee7aba246dbe 100644 (file)
@@ -1449,6 +1449,7 @@ func oneNewExtraM() {
        gp.syscallsp = gp.sched.sp
        gp.stktopsp = gp.sched.sp
        gp.gcscanvalid = true // fresh G, so no dequeueRescan necessary
+       gp.gcscandone = true
        gp.gcRescan = -1
        // malg returns status as Gidle, change to Gsyscall before adding to allg
        // where GC will see it.