Skip to content

Commit 4421333

Browse files
committed
runtime: symbolize morestack caller in throwsplit panic
This attempts to symbolize the PC of morestack's caller when there's a stack split at a bad time. The stack trace starts at the *caller* of the function that attempted to grow the stack, so this is useful if it isn't obvious what's being called at that point, such as in #21431. Change-Id: I5dee305d87c8069611de2d14e7a3083d76264f8f Reviewed-on: https://go-review.googlesource.com/84115 Run-TryBot: Austin Clements <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Cherry Zhang <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent bfb8f2a commit 4421333

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/runtime/stack.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,14 @@ func newstack() {
938938
morebuf := thisg.m.morebuf
939939
gp.syscallsp = morebuf.sp
940940
gp.syscallpc = morebuf.pc
941-
print("runtime: newstack sp=", hex(gp.sched.sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n",
941+
pcname, pcoff := "(unknown)", uintptr(0)
942+
f := findfunc(gp.sched.pc)
943+
if f.valid() {
944+
pcname = funcname(f)
945+
pcoff = gp.sched.pc - f.entry
946+
}
947+
print("runtime: newstack at ", pcname, "+", hex(pcoff),
948+
" sp=", hex(gp.sched.sp), " stack=[", hex(gp.stack.lo), ", ", hex(gp.stack.hi), "]\n",
942949
"\tmorebuf={pc:", hex(morebuf.pc), " sp:", hex(morebuf.sp), " lr:", hex(morebuf.lr), "}\n",
943950
"\tsched={pc:", hex(gp.sched.pc), " sp:", hex(gp.sched.sp), " lr:", hex(gp.sched.lr), " ctxt:", gp.sched.ctxt, "}\n")
944951

0 commit comments

Comments
 (0)