Commit c3e54f09 authored by Russ Cox's avatar Russ Cox
Browse files

runtime: better trace for fault due to nil pointer call

R=r
CC=golang-dev
https://golang.org/cl/854048
parent 03526597
master go1.12-nxd go18-fannkuch-entryshift go19 x/sched y/unqotechar-err weekly.2012-03-27 weekly.2012-03-22 weekly.2012-03-13 weekly.2012-03-04 weekly.2012-02-22 weekly.2012-02-14 weekly.2012-02-07 weekly.2012-01-27 weekly.2012-01-20 weekly.2012-01-15 weekly.2011-12-22 weekly.2011-12-14 weekly.2011-12-06 weekly.2011-12-02 weekly.2011-12-01 weekly.2011-11-18 weekly.2011-11-09 weekly.2011-11-08 weekly.2011-11-02 weekly.2011-11-01 weekly.2011-10-26 weekly.2011-10-25 weekly.2011-10-18 weekly.2011-10-06 weekly.2011-09-21 weekly.2011-09-16 weekly.2011-09-07 weekly.2011-09-01 weekly.2011-08-17 weekly.2011-08-10 weekly.2011-07-29 weekly.2011-07-19 weekly.2011-07-07 weekly.2011-06-23 weekly.2011-06-16 weekly.2011-06-09 weekly.2011-06-02 weekly.2011-05-22 weekly.2011-04-27 weekly.2011-04-13 weekly.2011-04-04 weekly.2011-03-28 weekly.2011-03-15 weekly.2011-03-07.1 weekly.2011-03-07 weekly.2011-02-24 weekly.2011-02-15 weekly.2011-02-01.1 weekly.2011-02-01 weekly.2011-01-20 weekly.2011-01-19 weekly.2011-01-12 weekly.2011-01-06 weekly.2010-12-22 weekly.2010-12-15.1 weekly.2010-12-15 weekly.2010-12-08 weekly.2010-12-02 weekly.2010-11-23 weekly.2010-11-10 weekly.2010-11-02 weekly.2010-10-27 weekly.2010-10-20 weekly.2010-10-13.1 weekly.2010-10-13 weekly.2010-09-29 weekly.2010-09-22 weekly.2010-09-15 weekly.2010-09-06 weekly.2010-08-25 weekly.2010-08-11 weekly.2010-08-04 weekly.2010-07-29 weekly.2010-07-14 weekly.2010-07-01 weekly.2010-06-21 weekly.2010-06-09 weekly.2010-05-27 weekly.2010-05-04 weekly.2010-04-27 weekly release.r60.3 release.r60.2 release.r60.1 release.r60 release.r59 release.r58.2 release.r58.1 release.r58 release.r57.2 release.r57.1 release.r57 release.r56 go1.9 go1.9rc2 go1.9rc1 go1.9beta2 go1.9beta1 go1.8.3 go1.8.2 go1.8.1 go1.8 go1.8rc3 go1.8rc2 go1.8rc1 go1.8beta2 go1.8beta1 go1.7.6 go1.7.5 go1.7.4 go1.7.3 go1.7.2 go1.7.1 go1.7 go1.7rc6 go1.7rc5 go1.7rc4 go1.7rc3 go1.7rc2 go1.7rc1 go1.7beta2 go1.7beta1 go1.6.4 go1.6.3 go1.6.2 go1.6.1 go1.6 go1.6rc2 go1.6rc1 go1.6beta2 go1.6beta1 go1.5.4 go1.5.3 go1.5.2 go1.5.1 go1.5 go1.5rc1 go1.5beta3 go1.5beta2 go1.5beta1 go1.4.3 go1.4.2 go1.4.1 go1.4 go1.4rc2 go1.4rc1 go1.4beta1 go1.3.3 go1.3.2 go1.3.1 go1.3 go1.3rc2 go1.3rc1 go1.3beta2 go1.3beta1 go1.2.2 go1.2.1 go1.2 go1.2rc5 go1.2rc4 go1.2rc3 go1.2rc2 go1.1.2 go1.1.1 go1.1 go1.1rc3 go1.1rc2 go1.0.3 go1.0.2 go1.0.1 go1
No related merge requests found
Showing with 72 additions and 20 deletions
+72 -20
...@@ -66,10 +66,18 @@ sighandler(int32 sig, Siginfo *info, void *context) ...@@ -66,10 +66,18 @@ sighandler(int32 sig, Siginfo *info, void *context)
gp->sigcode0 = info->si_code; gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr; gp->sigcode1 = (uintptr)info->si_addr;
sp = (uintptr*)r->esp; // Only push sigpanic if r->eip != 0.
*--sp = r->eip; // If r->eip == 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->eip != 0) {
sp = (uintptr*)r->esp;
*--sp = r->eip;
r->esp = (uintptr)sp;
}
r->eip = (uintptr)sigpanic; r->eip = (uintptr)sigpanic;
r->esp = (uintptr)sp;
return; return;
} }
......
...@@ -74,11 +74,19 @@ sighandler(int32 sig, Siginfo *info, void *context) ...@@ -74,11 +74,19 @@ sighandler(int32 sig, Siginfo *info, void *context)
gp->sig = sig; gp->sig = sig;
gp->sigcode0 = info->si_code; gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr; gp->sigcode1 = (uintptr)info->si_addr;
sp = (uintptr*)r->rsp; // Only push sigpanic if r->rip != 0.
*--sp = r->rip; // 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->rip = (uintptr)sigpanic;
r->rsp = (uintptr)sp;
return; return;
} }
......
...@@ -64,10 +64,18 @@ sighandler(int32 sig, Siginfo* info, void* context) ...@@ -64,10 +64,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code; gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr; gp->sigcode1 = (uintptr)info->si_addr;
sp = (uintptr*)r->mc_esp; // Only push sigpanic if r->mc_eip != 0.
*--sp = r->mc_eip; // If r->mc_eip == 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->mc_eip != 0) {
sp = (uintptr*)r->mc_esp;
*--sp = r->mc_eip;
r->mc_esp = (uintptr)sp;
}
r->mc_eip = (uintptr)sigpanic; r->mc_eip = (uintptr)sigpanic;
r->mc_esp = (uintptr)sp;
return; return;
} }
......
...@@ -72,10 +72,18 @@ sighandler(int32 sig, Siginfo* info, void* context) ...@@ -72,10 +72,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code; gp->sigcode0 = info->si_code;
gp->sigcode1 = (uintptr)info->si_addr; gp->sigcode1 = (uintptr)info->si_addr;
sp = (uintptr*)r->mc_rsp; // Only push sigpanic if r->mc_rip != 0.
*--sp = r->mc_rip; // If r->mc_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->mc_rip != 0) {
sp = (uintptr*)r->mc_rsp;
*--sp = r->mc_rip;
r->mc_rsp = (uintptr)sp;
}
r->mc_rip = (uintptr)sigpanic; r->mc_rip = (uintptr)sigpanic;
r->mc_rsp = (uintptr)sp;
return; return;
} }
......
...@@ -61,10 +61,18 @@ sighandler(int32 sig, Siginfo* info, void* context) ...@@ -61,10 +61,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code; gp->sigcode0 = info->si_code;
gp->sigcode1 = ((uintptr*)info)[3]; gp->sigcode1 = ((uintptr*)info)[3];
sp = (uintptr*)r->esp; // Only push sigpanic if r->eip != 0.
*--sp = r->eip; // If r->eip == 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->eip != 0) {
sp = (uintptr*)r->esp;
*--sp = r->eip;
r->esp = (uintptr)sp;
}
r->eip = (uintptr)sigpanic; r->eip = (uintptr)sigpanic;
r->esp = (uintptr)sp;
return; return;
} }
......
...@@ -71,10 +71,18 @@ sighandler(int32 sig, Siginfo* info, void* context) ...@@ -71,10 +71,18 @@ sighandler(int32 sig, Siginfo* info, void* context)
gp->sigcode0 = info->si_code; gp->sigcode0 = info->si_code;
gp->sigcode1 = ((uintptr*)info)[2]; gp->sigcode1 = ((uintptr*)info)[2];
sp = (uintptr*)r->rsp; // Only push sigpanic if r->rip != 0.
*--sp = r->rip; // 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->rip = (uintptr)sigpanic;
r->rsp = (uintptr)sp;
return; return;
} }
......
...@@ -70,7 +70,11 @@ sighandler(int32 sig, Siginfo *info, void *context) ...@@ -70,7 +70,11 @@ sighandler(int32 sig, Siginfo *info, void *context)
// If this is a leaf function, we do smash LR, // If this is a leaf function, we do smash LR,
// but we're not going back there anyway. // but we're not going back there anyway.
r->arm_lr = r->arm_pc; // Don't bother smashing if r->arm_pc is 0,
// which is probably a call to a nil func: the
// old link register is more useful in the stack trace.
if(r->arm_pc != 0)
r->arm_lr = r->arm_pc;
r->arm_pc = (uintptr)sigpanic; r->arm_pc = (uintptr)sigpanic;
return; return;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment