Commit b992c264 authored by Austin Clements's avatar Austin Clements

runtime: print SP/FP on bad pointer crashes

If the bad pointer is on a stack, this makes it possible to find the
frame containing the bad pointer.

Change-Id: Ieda44e054aa9ebf22d15d184457c7610b056dded
Reviewed-on: https://go-review.googlesource.com/37858
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: 's avatarRuss Cox <rsc@golang.org>
Reviewed-by: 's avatarKeith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent caa7dacf
...@@ -425,6 +425,7 @@ func heapBitsForObject(p, refBase, refOff uintptr) (base uintptr, hbits heapBits ...@@ -425,6 +425,7 @@ func heapBitsForObject(p, refBase, refOff uintptr) (base uintptr, hbits heapBits
print("runtime: found in object at *(", hex(refBase), "+", hex(refOff), ")\n") print("runtime: found in object at *(", hex(refBase), "+", hex(refOff), ")\n")
gcDumpObject("object", refBase, refOff) gcDumpObject("object", refBase, refOff)
} }
getg().m.traceback = 2
throw("found bad pointer in Go heap (incorrect use of unsafe or cgo?)") throw("found bad pointer in Go heap (incorrect use of unsafe or cgo?)")
} }
return return
......
...@@ -1230,6 +1230,7 @@ func greyobject(obj, base, off uintptr, hbits heapBits, span *mspan, gcw *gcWork ...@@ -1230,6 +1230,7 @@ func greyobject(obj, base, off uintptr, hbits heapBits, span *mspan, gcw *gcWork
// Dump the object // Dump the object
gcDumpObject("obj", obj, ^uintptr(0)) gcDumpObject("obj", obj, ^uintptr(0))
getg().m.traceback = 2
throw("checkmark found unmarked object") throw("checkmark found unmarked object")
} }
if hbits.isCheckmarked(span.elemsize) { if hbits.isCheckmarked(span.elemsize) {
...@@ -1244,6 +1245,7 @@ func greyobject(obj, base, off uintptr, hbits heapBits, span *mspan, gcw *gcWork ...@@ -1244,6 +1245,7 @@ func greyobject(obj, base, off uintptr, hbits heapBits, span *mspan, gcw *gcWork
print("runtime: marking free object ", hex(obj), " found at *(", hex(base), "+", hex(off), ")\n") print("runtime: marking free object ", hex(obj), " found at *(", hex(base), "+", hex(off), ")\n")
gcDumpObject("base", base, off) gcDumpObject("base", base, off)
gcDumpObject("obj", obj, ^uintptr(0)) gcDumpObject("obj", obj, ^uintptr(0))
getg().m.traceback = 2
throw("marking free object") throw("marking free object")
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment