runtime: distinct panic message for call of nil func value

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5531062
This commit is contained in:
Russ Cox 2012-01-10 11:46:57 -08:00
parent 57f15a3d03
commit 5032a7dc0c
6 changed files with 44 additions and 11 deletions

View file

@ -382,13 +382,19 @@ runtime·sigpanic(void)
{ {
switch(g->sig) { switch(g->sig) {
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGFPE: case SIGFPE:

View file

@ -128,13 +128,19 @@ runtime·sigpanic(void)
{ {
switch(g->sig) { switch(g->sig) {
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGFPE: case SIGFPE:

View file

@ -184,13 +184,19 @@ runtime·sigpanic(void)
{ {
switch(g->sig) { switch(g->sig) {
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
}
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGFPE: case SIGFPE:

View file

@ -175,13 +175,19 @@ runtime·sigpanic(void)
{ {
switch(g->sig) { switch(g->sig) {
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGFPE: case SIGFPE:

View file

@ -175,13 +175,19 @@ runtime·sigpanic(void)
{ {
switch(g->sig) { switch(g->sig) {
case SIGBUS: case SIGBUS:
if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGSEGV: case SIGSEGV:
if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) if((g->sigcode0 == 0 || g->sigcode0 == SEGV_MAPERR || g->sigcode0 == SEGV_ACCERR) && g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case SIGFPE: case SIGFPE:

View file

@ -270,8 +270,11 @@ runtime·sigpanic(void)
{ {
switch(g->sig) { switch(g->sig) {
case EXCEPTION_ACCESS_VIOLATION: case EXCEPTION_ACCESS_VIOLATION:
if(g->sigcode1 < 0x1000) if(g->sigcode1 < 0x1000) {
if(g->sigpc == 0)
runtime·panicstring("call of nil func value");
runtime·panicstring("invalid memory address or nil pointer dereference"); runtime·panicstring("invalid memory address or nil pointer dereference");
}
runtime·printf("unexpected fault address %p\n", g->sigcode1); runtime·printf("unexpected fault address %p\n", g->sigcode1);
runtime·throw("fault"); runtime·throw("fault");
case EXCEPTION_INT_DIVIDE_BY_ZERO: case EXCEPTION_INT_DIVIDE_BY_ZERO: