aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2016-01-13 12:45:52 -0500
committerRuss Cox <rsc@golang.org>2016-01-13 18:51:43 +0000
commit166cfd2c878a806897526ba7bfecda060323cba5 (patch)
treeeffadda752de00ae567bd5efaf26742d8f285860
parent756088549f764b7b75d4605d69cc1a187749fc6a (diff)
downloadgo-166cfd2c878a806897526ba7bfecda060323cba5.tar.gz
go-166cfd2c878a806897526ba7bfecda060323cba5.zip
runtime: arrange to show a few local variables when cgoCheckUnknownPointer panics
For #13934. Change-Id: Id399e35598def96f8bb89b9fcd1bf14ee06e2e62 Reviewed-on: https://go-review.googlesource.com/18612 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/runtime/cgocall.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/runtime/cgocall.go b/src/runtime/cgocall.go
index 9710c418b2..3b395fb8cd 100644
--- a/src/runtime/cgocall.go
+++ b/src/runtime/cgocall.go
@@ -498,7 +498,8 @@ func cgoCheckArg(t *_type, p unsafe.Pointer, indir, top bool, msg string) {
// cgoCheckUnknownPointer is called for an arbitrary pointer into Go
// memory. It checks whether that Go memory contains any other
// pointer into Go memory. If it does, we panic.
-func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) {
+// The return values are unused but useful to see in panic tracebacks.
+func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) (base, i uintptr) {
if cgoInRange(p, mheap_.arena_start, mheap_.arena_used) {
if !inheap(uintptr(p)) {
// This pointer is either to a stack or to an
@@ -508,12 +509,13 @@ func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) {
panic(errorString("cgo argument has invalid Go pointer"))
}
- base, hbits, span := heapBitsForObject(uintptr(p), 0, 0)
+ b, hbits, span := heapBitsForObject(uintptr(p), 0, 0)
+ base = b
if base == 0 {
return
}
n := span.elemsize
- for i := uintptr(0); i < n; i += sys.PtrSize {
+ for i = uintptr(0); i < n; i += sys.PtrSize {
bits := hbits.bits()
if i >= 2*sys.PtrSize && bits&bitMarked == 0 {
// No more possible pointers.
@@ -539,6 +541,8 @@ func cgoCheckUnknownPointer(p unsafe.Pointer, msg string) {
// In the text or noptr sections, we know that the
// pointer does not point to a Go pointer.
}
+
+ return
}
// cgoIsGoPointer returns whether the pointer is a Go pointer--a