]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: check for spanBytesAlloc underflow
authorAustin Clements <austin@google.com>
Fri, 11 Dec 2015 22:50:02 +0000 (17:50 -0500)
committerAustin Clements <austin@google.com>
Tue, 15 Dec 2015 16:15:47 +0000 (16:15 +0000)
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>
src/runtime/mgcsweep.go

index 22f51dbc1ab97be452e2255f73c39f6bdcdc6611..2cf6def33864889d6289085e932e612c361aa4ee 100644 (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) {