aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-12-19 22:55:53 -0500
committerAustin Clements <austin@google.com>2017-01-10 15:59:39 +0000
commit2817e77024a53aae31cc02c01a26fce0ebb11a79 (patch)
tree272b664f6f89986d8327651838df6f5ec9b6bb67
parent7f1ff65c3947b916cc4d0827fd8c1307d7efd7bf (diff)
downloadgo-2817e77024a53aae31cc02c01a26fce0ebb11a79.tar.gz
go-2817e77024a53aae31cc02c01a26fce0ebb11a79.zip
runtime: debug prints for spanBytesAlloc underflow
Updates #18043. Change-Id: I24e687fdd5521c48b672987f15f0d5de9f308884 Reviewed-on: https://go-review.googlesource.com/34612 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Rick Hudson <rlh@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/runtime/mgcsweep.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go
index e74a451d0d..fb5c488ffc 100644
--- a/src/runtime/mgcsweep.go
+++ b/src/runtime/mgcsweep.go
@@ -405,7 +405,10 @@ func reimburseSweepCredit(unusableBytes uintptr) {
// Nobody cares about the credit. Avoid the atomic.
return
}
- if int64(atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))) < 0 {
+ nval := atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))
+ if int64(nval) < 0 {
+ // Debugging for #18043.
+ print("runtime: bad spanBytesAlloc=", nval, " (was ", nval+uint64(unusableBytes), ") unusableBytes=", unusableBytes, " sweepPagesPerByte=", mheap_.sweepPagesPerByte, "\n")
throw("spanBytesAlloc underflow")
}
}