1
0
mirror of https://github.com/golang/go synced 2024-11-23 18:00:06 -07:00

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>
This commit is contained in:
Austin Clements 2015-12-11 17:50:02 -05:00
parent 6383fb6152
commit c1cbe5b577

View File

@ -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) {