mirror of
https://github.com/golang/go
synced 2024-11-12 05:30:21 -07:00
runtime: handle fault during runtime more like unexpected fault address
Delaying the runtime.throw until here will print more information. In particular it will print the signal and code values, which means it will show the fault address. The canpanic checks were added recently, in CL 75320043. They were just not added in exactly the right place. LGTM=iant R=dvyukov, iant CC=golang-codereviews https://golang.org/cl/83980043
This commit is contained in:
parent
f5f5a8b620
commit
4110271501
@ -434,6 +434,9 @@ runtime·mach_semrelease(uint32 sem)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGBUS:
|
||||
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -169,6 +169,9 @@ runtime·unminit(void)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGBUS:
|
||||
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -177,6 +177,9 @@ runtime·unminit(void)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGBUS:
|
||||
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -218,6 +218,9 @@ runtime·unminit(void)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGBUS:
|
||||
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -247,6 +247,9 @@ runtime·closeonexec(int32)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
// Native Client only invokes the exception handler for memory faults.
|
||||
g->sig = SIGSEGV;
|
||||
if(g->sigpc == 0)
|
||||
|
@ -237,6 +237,9 @@ runtime·unminit(void)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGBUS:
|
||||
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -214,6 +214,9 @@ runtime·unminit(void)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGBUS:
|
||||
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -352,6 +352,9 @@ runtime·sigpanic(void)
|
||||
{
|
||||
byte *p;
|
||||
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGRFAULT:
|
||||
case SIGWFAULT:
|
||||
|
@ -71,9 +71,6 @@ runtime·sighandler(void *v, int8 *note, G *gp)
|
||||
runtime·exits(note+9); // Strip "go: exit " prefix.
|
||||
|
||||
if(flags & SigPanic) {
|
||||
if(!runtime·canpanic(gp))
|
||||
goto Throw;
|
||||
|
||||
// Copy the error string from sigtramp's stack into m->notesig so
|
||||
// we can reliably access it from the panic routines.
|
||||
runtime·memmove(m->notesig, note, len+1);
|
||||
|
@ -79,9 +79,6 @@ runtime·sighandler(void *v, int8 *note, G *gp)
|
||||
runtime·exits(note+9); // Strip "go: exit " prefix.
|
||||
|
||||
if(flags & SigPanic) {
|
||||
if(!runtime·canpanic(gp))
|
||||
goto Throw;
|
||||
|
||||
// Copy the error string from sigtramp's stack into m->notesig so
|
||||
// we can reliably access it from the panic routines.
|
||||
runtime·memmove(m->notesig, note, len+1);
|
||||
|
@ -209,6 +209,9 @@ runtime·unminit(void)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case SIGBUS:
|
||||
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -346,6 +346,9 @@ runtime·issigpanic(uint32 code)
|
||||
void
|
||||
runtime·sigpanic(void)
|
||||
{
|
||||
if(!runtime·canpanic(g))
|
||||
runtime·throw("unexpected signal during runtime execution");
|
||||
|
||||
switch(g->sig) {
|
||||
case EXCEPTION_ACCESS_VIOLATION:
|
||||
if(g->sigcode1 < 0x1000 || g->paniconfault) {
|
||||
|
@ -45,9 +45,6 @@ runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp)
|
||||
|
||||
t = &runtime·sigtab[sig];
|
||||
if(SIG_CODE0(info, ctxt) != SI_USER && (t->flags & SigPanic)) {
|
||||
if(!runtime·canpanic(gp))
|
||||
goto Throw;
|
||||
|
||||
// Make it look like a call to the signal func.
|
||||
// Have to pass arguments out of band since
|
||||
// augmenting the stack frame would break
|
||||
@ -94,7 +91,6 @@ runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp)
|
||||
if(!(t->flags & SigThrow))
|
||||
return;
|
||||
|
||||
Throw:
|
||||
m->throwing = 1;
|
||||
m->caughtsig = gp;
|
||||
runtime·startpanic();
|
||||
|
@ -54,9 +54,6 @@ runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp)
|
||||
|
||||
t = &runtime·sigtab[sig];
|
||||
if(SIG_CODE0(info, ctxt) != SI_USER && (t->flags & SigPanic)) {
|
||||
if(!runtime·canpanic(gp))
|
||||
goto Throw;
|
||||
|
||||
// Make it look like a call to the signal func.
|
||||
// Have to pass arguments out of band since
|
||||
// augmenting the stack frame would break
|
||||
@ -107,7 +104,6 @@ runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp)
|
||||
if(!(t->flags & SigThrow))
|
||||
return;
|
||||
|
||||
Throw:
|
||||
m->throwing = 1;
|
||||
m->caughtsig = gp;
|
||||
runtime·startpanic();
|
||||
|
@ -52,9 +52,6 @@ runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp)
|
||||
|
||||
t = &runtime·sigtab[sig];
|
||||
if(SIG_CODE0(info, ctxt) != SI_USER && (t->flags & SigPanic)) {
|
||||
if(!runtime·canpanic(gp))
|
||||
goto Throw;
|
||||
|
||||
// Make it look like a call to the signal func.
|
||||
// Have to pass arguments out of band since
|
||||
// augmenting the stack frame would break
|
||||
@ -92,7 +89,6 @@ runtime·sighandler(int32 sig, Siginfo *info, void *ctxt, G *gp)
|
||||
if(!(t->flags & SigThrow))
|
||||
return;
|
||||
|
||||
Throw:
|
||||
m->throwing = 1;
|
||||
m->caughtsig = gp;
|
||||
if(runtime·panicking) // traceback already printed
|
||||
|
Loading…
Reference in New Issue
Block a user