Skip to content

Commit 6469954

Browse files
committed
runtime: assert p.destroy runs with GC not running
This is already guaranteed by stopTheWorldGC prior to procresize. Thus the cleanup code here is dead, which is a bit confusing. Replace it with a throw for clarity. Change-Id: I6a6a636c8ca1487b720c4fab41b2b86c13d1d9e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/709655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
1 parent 4c0fd3a commit 6469954

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/runtime/proc.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5818,11 +5818,13 @@ func (pp *p) destroy() {
58185818
// Move all timers to the local P.
58195819
getg().m.p.ptr().timers.take(&pp.timers)
58205820

5821-
// Flush p's write barrier buffer.
5822-
if gcphase != _GCoff {
5823-
wbBufFlush1(pp)
5824-
pp.gcw.dispose()
5821+
// No need to flush p's write barrier buffer or span queue, as Ps
5822+
// cannot be destroyed during the mark phase.
5823+
if phase := gcphase; phase != _GCoff {
5824+
println("runtime: p id", pp.id, "destroyed during GC phase", phase)
5825+
throw("P destroyed while GC is running")
58255826
}
5827+
58265828
clear(pp.sudogbuf[:])
58275829
pp.sudogcache = pp.sudogbuf[:0]
58285830
pp.pinnerCache = nil

0 commit comments

Comments
 (0)