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 | e56c6e75353d32a97a301d4890b58a4e10963d82 (patch) | |
| tree | 9b966f33cda2ca69d863d11ec638006ccbb40a52 /src/pkg/runtime/os_linux.c | |
| parent | 67c83db60db744c17316a4dc1d590c9649d66e6c (diff) | |
| download | go-e56c6e75353d32a97a301d4890b58a4e10963d82.tar.xz | |
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://golang.org/cl/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 130e1059ec..b4be9406ec 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"); |
