Commit 68b0a879 authored by Russ Cox's avatar Russ Cox

runtime: do not fall through in SIGBUS/SIGSEGV

Faults beyond the first page are not expected
and should fail loudly.  They are not subject to recover.

R=r
CC=golang-dev
https://golang.org/cl/1915042
parent a0368180
...@@ -453,11 +453,13 @@ sigpanic(void) ...@@ -453,11 +453,13 @@ sigpanic(void)
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000)
panicstring("invalid memory address or nil pointer dereference"); panicstring("invalid memory address or nil pointer dereference");
break; printf("unexpected fault address %p\n", g->sigcode1);
throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR) && g->sigcode1 < 0x1000)
panicstring("invalid memory address or nil pointer dereference"); panicstring("invalid memory address or nil pointer dereference");
break; printf("unexpected fault address %p\n", g->sigcode1);
throw("fault");
case SIGFPE: case SIGFPE:
switch(g->sigcode0) { switch(g->sigcode0) {
case FPE_INTDIV: case FPE_INTDIV:
......
...@@ -179,11 +179,13 @@ sigpanic(void) ...@@ -179,11 +179,13 @@ sigpanic(void)
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000)
panicstring("invalid memory address or nil pointer dereference"); panicstring("invalid memory address or nil pointer dereference");
break; printf("unexpected fault address %p\n", g->sigcode1);
throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR) && g->sigcode1 < 0x1000)
panicstring("invalid memory address or nil pointer dereference"); panicstring("invalid memory address or nil pointer dereference");
break; printf("unexpected fault address %p\n", g->sigcode1);
throw("fault");
case SIGFPE: case SIGFPE:
switch(g->sigcode0) { switch(g->sigcode0) {
case FPE_INTDIV: case FPE_INTDIV:
......
...@@ -279,11 +279,13 @@ sigpanic(void) ...@@ -279,11 +279,13 @@ sigpanic(void)
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000)
panicstring("invalid memory address or nil pointer dereference"); panicstring("invalid memory address or nil pointer dereference");
break; printf("unexpected fault address %p\n", g->sigcode1);
throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR) && g->sigcode1 < 0x1000)
panicstring("invalid memory address or nil pointer dereference"); panicstring("invalid memory address or nil pointer dereference");
break; printf("unexpected fault address %p\n", g->sigcode1);
throw("fault");
case SIGFPE: case SIGFPE:
switch(g->sigcode0) { switch(g->sigcode0) {
case FPE_INTDIV: case FPE_INTDIV:
......
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