mirror of
https://github.com/golang/go
synced 2024-11-13 17:20:22 -07:00
runtime: improve diagnostics for "scan missed a g"
Currently there are no diagnostics for mark root check during marking. Fix this by printing out the same diagnostics we print during mark termination. Also, drop the allglock before throwing. Holding that across a throw causes a self-deadlock with tracebackothers. For #16083. Change-Id: Ib605f3ae0c17e70704b31d8378274cfaa2307dc2 Reviewed-on: https://go-review.googlesource.com/33339 Reviewed-by: Rick Hudson <rlh@golang.org>
This commit is contained in:
parent
7061dc3f6e
commit
05dc6b26ca
@ -126,26 +126,32 @@ func gcMarkRootCheck() {
|
|||||||
|
|
||||||
lock(&allglock)
|
lock(&allglock)
|
||||||
// Check that stacks have been scanned.
|
// Check that stacks have been scanned.
|
||||||
|
var gp *g
|
||||||
if gcphase == _GCmarktermination && debug.gcrescanstacks > 0 {
|
if gcphase == _GCmarktermination && debug.gcrescanstacks > 0 {
|
||||||
for i := 0; i < len(allgs); i++ {
|
for i := 0; i < len(allgs); i++ {
|
||||||
gp := allgs[i]
|
gp = allgs[i]
|
||||||
if !(gp.gcscandone && gp.gcscanvalid) && readgstatus(gp) != _Gdead {
|
if !(gp.gcscandone && gp.gcscanvalid) && readgstatus(gp) != _Gdead {
|
||||||
println("gp", gp, "goid", gp.goid,
|
goto fail
|
||||||
"status", readgstatus(gp),
|
|
||||||
"gcscandone", gp.gcscandone,
|
|
||||||
"gcscanvalid", gp.gcscanvalid)
|
|
||||||
throw("scan missed a g")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for i := 0; i < work.nStackRoots; i++ {
|
for i := 0; i < work.nStackRoots; i++ {
|
||||||
gp := allgs[i]
|
gp = allgs[i]
|
||||||
if !gp.gcscandone {
|
if !gp.gcscandone {
|
||||||
throw("scan missed a g")
|
goto fail
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unlock(&allglock)
|
unlock(&allglock)
|
||||||
|
return
|
||||||
|
|
||||||
|
fail:
|
||||||
|
println("gp", gp, "goid", gp.goid,
|
||||||
|
"status", readgstatus(gp),
|
||||||
|
"gcscandone", gp.gcscandone,
|
||||||
|
"gcscanvalid", gp.gcscanvalid)
|
||||||
|
unlock(&allglock) // Avoid self-deadlock with traceback.
|
||||||
|
throw("scan missed a g")
|
||||||
}
|
}
|
||||||
|
|
||||||
// ptrmask for an allocation containing a single pointer.
|
// ptrmask for an allocation containing a single pointer.
|
||||||
|
Loading…
Reference in New Issue
Block a user