]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: print SP/FP on bad pointer crashes
authorAustin Clements <austin@google.com>
Tue, 7 Mar 2017 20:20:40 +0000 (15:20 -0500)
committerAustin Clements <austin@google.com>
Tue, 7 Mar 2017 20:46:54 +0000 (20:46 +0000)
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: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/runtime/mbitmap.go
src/runtime/mgcmark.go

index 3e782f50da0f0a7f46becd19a52770b7285059a9..4e1a3e29f9937f2062fc3fbd7c2d5f2007b92e12 100644 (file)
@@ -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")
                                gcDumpObject("object", refBase, refOff)
                        }
+                       getg().m.traceback = 2
                        throw("found bad pointer in Go heap (incorrect use of unsafe or cgo?)")
                }
                return
index 2b45881976af9f9522a15fce13eb3122d640c0d7..dd7a2bd8eb8938a34fb2581bb94e19736a60517d 100644 (file)
@@ -1230,6 +1230,7 @@ func greyobject(obj, base, off uintptr, hbits heapBits, span *mspan, gcw *gcWork
                        // Dump the object
                        gcDumpObject("obj", obj, ^uintptr(0))
 
+                       getg().m.traceback = 2
                        throw("checkmark found unmarked object")
                }
                if hbits.isCheckmarked(span.elemsize) {
@@ -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")
                        gcDumpObject("base", base, off)
                        gcDumpObject("obj", obj, ^uintptr(0))
+                       getg().m.traceback = 2
                        throw("marking free object")
                }