summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/darwin/amd64/signal.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/darwin/amd64/signal.c')
-rw-r--r--src/pkg/runtime/darwin/amd64/signal.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/pkg/runtime/darwin/amd64/signal.c b/src/pkg/runtime/darwin/amd64/signal.c
index 9c4f0dc14..56f02e56d 100644
--- a/src/pkg/runtime/darwin/amd64/signal.c
+++ b/src/pkg/runtime/darwin/amd64/signal.c
@@ -74,11 +74,19 @@ sighandler(int32 sig, Siginfo *info, void *context)
gp->sig = sig;
gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr;
-
- 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;
}