Skip to content

Commit ab59235

Browse files
committed
runtime: consistency check for G rescan position
Issue #17099 shows a failure that indicates we rescanned a stack twice concurrently during mark termination, which suggests that the rescan list became inconsistent. Add a simple check when we dequeue something from the rescan list that it claims to be at the index where we found it. Change-Id: I6a267da4154a2e7b7d430cb4056e6bae978eaf62 Reviewed-on: https://go-review.googlesource.com/29280 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
1 parent 39ce6eb commit ab59235

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/runtime/mgcmark.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ func markroot(gcw *gcWork, i uint32) {
199199
gp = allgs[i-baseStacks]
200200
} else if baseRescan <= i && i < end {
201201
gp = work.rescan.list[i-baseRescan].ptr()
202+
if gp.gcRescan != int32(i-baseRescan) {
203+
// Looking for issue #17099.
204+
println("runtime: gp", gp, "found at rescan index", i-baseRescan, "but should be at", gp.gcRescan)
205+
throw("bad g rescan index")
206+
}
202207
} else {
203208
throw("markroot: bad index")
204209
}

0 commit comments

Comments
 (0)