aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2025-10-06 17:28:37 -0400
committerMichael Pratt <mpratt@google.com>2025-10-07 12:16:53 -0700
commit3ee761739b0cbb074f5a6e8b28b491664ec1414a (patch)
treeb3b7d00a16e018c74135c5124e02382f65927b3d /src/runtime/proc.go
parent8709a41d5ef7321f486a1857f189c3fee20e8edd (diff)
downloadgo-3ee761739b0cbb074f5a6e8b28b491664ec1414a.tar.xz
runtime: free spanQueue on P destroy
Span queues must be empty when destroying a P since we are outside of the mark phase. But we don't actually free them, so they simply sit around using memory. More importantly, they are still in work.spanSPMCs.all, so freeDeadSpanSPMCs must continue traversing past them until the end of time. Prior to CL 709575, keeping them in work.spanSPMCs.all allowed programs with low GOMAXPROCS to continue triggering the bug if they ever had high GOMAXPROCS in the past. The spanSPMCs list is singly-linked, so it is not efficient to remove a random element from the middle. Instead, we simply mark it as dead to all freeDeadSpanSPMCs to free it when it scans the full list. For #75771. Change-Id: I6a6a636cfa22a4bdef0c273d083c91553e923fe5 Reviewed-on: https://go-review.googlesource.com/c/go/+/709656 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Diffstat (limited to 'src/runtime/proc.go')
-rw-r--r--src/runtime/proc.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/runtime/proc.go b/src/runtime/proc.go
index d36895b046..fadd9a5963 100644
--- a/src/runtime/proc.go
+++ b/src/runtime/proc.go
@@ -5824,6 +5824,8 @@ func (pp *p) destroy() {
println("runtime: p id", pp.id, "destroyed during GC phase", phase)
throw("P destroyed while GC is running")
}
+ // We should free the queues though.
+ pp.gcw.spanq.destroy()
clear(pp.sudogbuf[:])
pp.sudogcache = pp.sudogbuf[:0]