aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2015-12-11 17:50:02 -0500
committerAustin Clements <austin@google.com>2015-12-15 16:15:47 +0000
commitc1cbe5b577b1bfdc34be18f391ab82904b6530f2 (patch)
treecffd6f89cabd435945b74e951e44e44865a7c902 /src
parent6383fb615205f1b0d0ce8f8c4329e8825807edd0 (diff)
downloadgo-c1cbe5b577b1bfdc34be18f391ab82904b6530f2.tar.xz
runtime: check for spanBytesAlloc underflow
Change-Id: I5e6739ff0c6c561195ed9891fb90f933b81e7750 Reviewed-on: https://go-review.googlesource.com/17746 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mgcsweep.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/mgcsweep.go b/src/runtime/mgcsweep.go
index 22f51dbc1a..2cf6def338 100644
--- a/src/runtime/mgcsweep.go
+++ b/src/runtime/mgcsweep.go
@@ -393,7 +393,9 @@ func reimburseSweepCredit(unusableBytes uintptr) {
// Nobody cares about the credit. Avoid the atomic.
return
}
- atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))
+ if int64(atomic.Xadd64(&mheap_.spanBytesAlloc, -int64(unusableBytes))) < 0 {
+ throw("spanBytesAlloc underflow")
+ }
}
func dumpFreeList(s *mspan) {