aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-10-03 16:18:17 -0400
committerAustin Clements <austin@google.com>2016-10-26 15:46:00 +0000
commitd1cc83472d611a17513795676d650276f823cafd (patch)
treefd50d8e54e54309ed1429543540cf7e5202d76bd /src/runtime
parent79561a84ceb4435c1294767d26b0b8a0dd77809d (diff)
downloadgo-d1cc83472d611a17513795676d650276f823cafd.tar.xz
runtime: debug code to panic when marking a free object
This adds debug code enabled in gccheckmark mode that panics if we attempt to mark an unallocated object. This is a common issue with the hybrid barrier when we're manipulating uninitialized memory that contains stale pointers. This also tends to catch bugs that will lead to "sweep increased allocation count" crashes closer to the source of the bug. Change-Id: I443ead3eac6f316a46f50b106078b524cac317f4 Reviewed-on: https://go-review.googlesource.com/31761 Reviewed-by: Rick Hudson <rlh@golang.org>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/mgcmark.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go
index e47072d88c..e62e470217 100644
--- a/src/runtime/mgcmark.go
+++ b/src/runtime/mgcmark.go
@@ -1294,6 +1294,13 @@ func greyobject(obj, base, off uintptr, hbits heapBits, span *mspan, gcw *gcWork
throw("setCheckmarked and isCheckmarked disagree")
}
} else {
+ if debug.gccheckmark > 0 && span.isFree(objIndex) {
+ print("runtime: marking free object ", hex(obj), " found at *(", hex(base), "+", hex(off), ")\n")
+ gcDumpObject("base", base, off)
+ gcDumpObject("obj", obj, ^uintptr(0))
+ throw("marking free object")
+ }
+
// If marked we have nothing to do.
if mbits.isMarked() {
return