From: Austin Clements Date: Mon, 8 Oct 2018 23:24:46 +0000 (-0400) Subject: runtime: fix non-in-use span check X-Git-Tag: go1.12beta1~846 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7d2f46dacddba279c5b6b7520c7f6a475e6fffbc;p=gostls13.git runtime: fix non-in-use span check Lazy mcache flushing (golang.org/cl/134783) introduced a second value for sweepgen that indicates a span has been swept. I missed adding this case to a sanity check in sweepone, so it can now panic if it finds a non-in-use spans that's been swept *and* put in an mcache. Fix this by adding the second sweepgen case to this check. Fixes #27997. Change-Id: I568d9f2cc8923396ca897a37d154cd2c859c7bef Reviewed-on: https://go-review.googlesource.com/c/140697 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go index 104bd868fa..b7528ab68f 100644 --- a/src/runtime/mgcsweep.go +++ b/src/runtime/mgcsweep.go @@ -101,7 +101,7 @@ func sweepone() uintptr { // This can happen if direct sweeping already // swept this span, but in that case the sweep // generation should always be up-to-date. - if s.sweepgen != sg { + if !(s.sweepgen == sg || s.sweepgen == sg+3) { print("runtime: bad span s.state=", s.state, " s.sweepgen=", s.sweepgen, " sweepgen=", sg, "\n") throw("non in-use span in unswept list") }