diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 49147ff8381e3b..23d108dc6b7855 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -182,6 +182,17 @@ func gentraceback(pc0, sp0, lr0 uintptr, gp *g, skip int, pcbuf *uintptr, max in case funcID_systemstack: // systemstack returns normally, so just follow the // stack transition. + if usesLR && funcspdelta(f, frame.pc, &cache) == 0 { + // We're at the function prologue and the stack + // switch hasn't happened, or epilogue where we're + // about to return. Just unwind normally. + // Do this only on LR machines because on x86 + // systemstack doesn't have an SP delta (the CALL + // instruction opens the frame), therefore no way + // to check. + flag &^= funcFlag_SPWRITE + break + } frame.sp = gp.m.curg.sched.sp stack = gp.m.curg.stack cgoCtxt = gp.m.curg.cgoCtxt