Skip to content

Commit 2817e77

Browse files
committed
runtime: debug prints for spanBytesAlloc underflow
Updates #18043. Change-Id: I24e687fdd5521c48b672987f15f0d5de9f308884 Reviewed-on: https://go-review.googlesource.com/34612 Run-TryBot: Austin Clements <[email protected]> Reviewed-by: Rick Hudson <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent 7f1ff65 commit 2817e77

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/runtime/mgcsweep.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,10 @@ func reimburseSweepCredit(unusableBytes uintptr) {
405405
// Nobody cares about the credit. Avoid the atomic.
406406
return
407407
}
408-
if int64(atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))) < 0 {
408+
nval := atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))
409+
if int64(nval) < 0 {
410+
// Debugging for #18043.
411+
print("runtime: bad spanBytesAlloc=", nval, " (was ", nval+uint64(unusableBytes), ") unusableBytes=", unusableBytes, " sweepPagesPerByte=", mheap_.sweepPagesPerByte, "\n")
409412
throw("spanBytesAlloc underflow")
410413
}
411414
}

0 commit comments

Comments
 (0)