From 0c22a74e8594ee88c54a7716e710e788bd960bd2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 28 Jul 2015 20:50:00 +0200 Subject: [PATCH] runtime: fix out-of-bounds in stack debugging Currently stackDebug=4 crashes as: panic: runtime error: index out of range fatal error: panic on system stack runtime stack: runtime.throw(0x607470, 0x15) src/runtime/panic.go:527 +0x96 runtime.gopanic(0x5ada00, 0xc82000a1d0) src/runtime/panic.go:354 +0xb9 runtime.panicindex() src/runtime/panic.go:12 +0x49 runtime.adjustpointers(0xc820065ac8, 0x7ffe58b56100, 0x7ffe58b56318, 0x0) src/runtime/stack1.go:428 +0x5fb runtime.adjustframe(0x7ffe58b56200, 0x7ffe58b56318, 0x1) src/runtime/stack1.go:542 +0x780 runtime.gentraceback(0x487760, 0xc820065ac0, 0x0, 0xc820001080, 0x0, 0x0, 0x7fffffff, 0x6341b8, 0x7ffe58b56318, 0x0, ...) src/runtime/traceback.go:336 +0xa7e runtime.copystack(0xc820001080, 0x1000) src/runtime/stack1.go:616 +0x3b1 runtime.newstack() src/runtime/stack1.go:801 +0xdde Change-Id: If2d60960231480a9dbe545d87385fe650d6db808 Reviewed-on: https://go-review.googlesource.com/12763 Reviewed-by: Russ Cox --- src/runtime/stack1.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/stack1.go b/src/runtime/stack1.go index 113334b0d60..efcb5f25fad 100644 --- a/src/runtime/stack1.go +++ b/src/runtime/stack1.go @@ -425,7 +425,7 @@ func adjustpointers(scanp unsafe.Pointer, cbv *bitvector, adjinfo *adjustinfo, f num := uintptr(bv.n) for i := uintptr(0); i < num; i++ { if stackDebug >= 4 { - print(" ", add(scanp, i*ptrSize), ":", ptrnames[ptrbit(&bv, i)], ":", hex(*(*uintptr)(add(scanp, i*ptrSize))), " # ", i, " ", bv.bytedata[i/4], "\n") + print(" ", add(scanp, i*ptrSize), ":", ptrnames[ptrbit(&bv, i)], ":", hex(*(*uintptr)(add(scanp, i*ptrSize))), " # ", i, " ", bv.bytedata[i/8], "\n") } if ptrbit(&bv, i) == 1 { pp := (*uintptr)(add(scanp, i*ptrSize))