diff options
author | Russ Cox <rsc@golang.org> | 2014-02-20 16:18:05 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2014-02-20 16:18:05 -0500 |
commit | ed591404c19dffaf84876d8e3d75db926b78a130 (patch) | |
tree | bd9764edb7953c1b09a4ac8231c994e370947744 /src/pkg/runtime/os_linux.c | |
parent | 50be4ad5a71a5db95c620805be653d41c7d41ebd (diff) | |
download | go-ed591404c19dffaf84876d8e3d75db926b78a130.tar.gz |
runtime/debug: add SetPanicOnFault
SetPanicOnFault allows recovery from unexpected memory faults.
This can be useful if you are using a memory-mapped file
or probing the address space of the current program.
LGTM=r
R=r
CC=golang-codereviews
https://codereview.appspot.com/66590044
Diffstat (limited to 'src/pkg/runtime/os_linux.c')
-rw-r--r-- | src/pkg/runtime/os_linux.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/pkg/runtime/os_linux.c b/src/pkg/runtime/os_linux.c index 130e1059e..b4be9406e 100644 --- a/src/pkg/runtime/os_linux.c +++ b/src/pkg/runtime/os_linux.c @@ -220,7 +220,7 @@ runtime·sigpanic(void) { switch(g->sig) { case SIGBUS: - if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000) { + if(g->sigcode0 == BUS_ADRERR && g->sigcode1 < 0x1000 || g->paniconfault) { if(g->sigpc == 0) runtime·panicstring("call of nil func value"); runtime·panicstring("invalid memory address or nil pointer dereference"); @@ -228,7 +228,7 @@ runtime·sigpanic(void) 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 || g->paniconfault) { if(g->sigpc == 0) runtime·panicstring("call of nil func value"); runtime·panicstring("invalid memory address or nil pointer dereference"); |