summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/linux/amd64/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/linux/amd64/signal.c')
-rw-r--r--src/pkg/runtime/linux/amd64/signal.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/pkg/runtime/linux/amd64/signal.c b/src/pkg/runtime/linux/amd64/signal.c
index 57cdea132..fbe6599f6 100644
--- a/src/pkg/runtime/linux/amd64/signal.c
+++ b/src/pkg/runtime/linux/amd64/signal.c
@@ -71,10 +71,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code;
gp->sigcode1 = ((uintptr*)info)[2];
- sp = (uintptr*)r->rsp;
- *--sp = r->rip;
+ // Only push sigpanic if r->rip != 0.
+ // If r->rip == 0, probably panicked because of a
+ // call to a nil func. Not pushing that onto sp will
+ // make the trace look like a call to sigpanic instead.
+ // (Otherwise the trace will end at sigpanic and we
+ // won't get to see who faulted.)
+ if(r->rip != 0) {
+ sp = (uintptr*)r->rsp;
+ *--sp = r->rip;
+ r->rsp = (uintptr)sp;
+ }
r->rip = (uintptr)sigpanic;
- r->rsp = (uintptr)sp;
return;
}