]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: distinct panic message for call of nil func value
authorRuss Cox <rsc@golang.org>
Tue, 10 Jan 2012 19:46:57 +0000 (11:46 -0800)
committerRuss Cox <rsc@golang.org>
Tue, 10 Jan 2012 19:46:57 +0000 (11:46 -0800)
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/5531062

src/pkg/runtime/thread_darwin.c
src/pkg/runtime/thread_freebsd.c
src/pkg/runtime/thread_linux.c
src/pkg/runtime/thread_netbsd.c
src/pkg/runtime/thread_openbsd.c
src/pkg/runtime/thread_windows.c

index 12e79afda033c0aeb1653de9f93b7e0fc2799265..22800e2e894712913201bff7b93418ff6cae2249 100644 (file)
@@ -382,13 +382,19 @@ runtime·sigpanic(void)
 {
        switch(g->sig) {
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        case SIGFPE:
index 53c1b1bbfac9b35f517cb4438361b6b8f285d3f2..1c48865a231685ce09c35810b4a00823bc7978ef 100644 (file)
@@ -128,13 +128,19 @@ runtime·sigpanic(void)
 {
        switch(g->sig) {
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        case SIGFPE:
index d72e9cb43525da199b252a046f0c5b002a1c839f..d18574145bd6dd001fd440373ff2bc605ec61d64 100644 (file)
@@ -184,13 +184,19 @@ runtime·sigpanic(void)
 {
        switch(g->sig) {
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        case SIGFPE:
index 0aba02720e0160f81573201c06ccc3b0e06657f7..cba7adecf5b72745f020cfa0f099b941cbee4837 100644 (file)
@@ -175,13 +175,19 @@ runtime·sigpanic(void)
 {
        switch(g->sig) {
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        case SIGFPE:
index e1cd5bf2e416ac9c924cbe1ae8bd5a450a37e3a8..efe03e3711b0b86b18220097d268e815bf5431d1 100644 (file)
@@ -175,13 +175,19 @@ runtime·sigpanic(void)
 {
        switch(g->sig) {
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        case SIGFPE:
index ad66c93a64e1e571736c60f0a9263dbedf33768e..516d1d0d181f1e9156013056c6b7d3c91c758dac 100644 (file)
@@ -270,8 +270,11 @@ runtime·sigpanic(void)
 {
        switch(g->sig) {
        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·printf("unexpected fault address %p\n", g->sigcode1);
                runtime·throw("fault");
        case EXCEPTION_INT_DIVIDE_BY_ZERO: