diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2013-03-23 11:28:53 +0100 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-03-23 11:28:53 +0100 |
commit | b39e15dde5ec7b96c15da9faf4ab5892501c1aae (patch) | |
tree | 718cede1f6ca97d082c6c40b7dc3f4f6148253c0 /src/pkg/runtime/panic.c | |
parent | 04b08da9af0c450d645ab7389d1467308cfc2db8 (diff) | |
download | golang-upstream/1.1_hg20130323.tar.gz |
Imported Upstream version 1.1~hg20130323upstream/1.1_hg20130323
Diffstat (limited to 'src/pkg/runtime/panic.c')
-rw-r--r-- | src/pkg/runtime/panic.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/pkg/runtime/panic.c b/src/pkg/runtime/panic.c index 2f553f417..d0cf3ad6f 100644 --- a/src/pkg/runtime/panic.c +++ b/src/pkg/runtime/panic.c @@ -5,6 +5,7 @@ #include "runtime.h" #include "arch_GOARCH.h" #include "stack.h" +#include "malloc.h" // Code related to defer, panic and recover. @@ -383,7 +384,10 @@ nomatch: void runtime·startpanic(void) { - if(m->mcache == nil) // can happen if called from signal handler or throw + if(runtime·mheap == 0 || runtime·mheap->cachealloc.size == 0) { // very early + runtime·printf("runtime: panic before malloc heap initialized\n"); + m->mallocing = 1; // tell rest of panic not to try to malloc + } else if(m->mcache == nil) // can happen if called from signal handler or throw m->mcache = runtime·allocmcache(); if(m->dying) { runtime·printf("panic during panic\n"); @@ -398,12 +402,13 @@ void runtime·dopanic(int32 unused) { static bool didothers; + bool crash; if(g->sig != 0) runtime·printf("[signal %x code=%p addr=%p pc=%p]\n", g->sig, g->sigcode0, g->sigcode1, g->sigpc); - if(runtime·gotraceback()){ + if(runtime·gotraceback(&crash)){ if(g != m->g0) { runtime·printf("\n"); runtime·goroutineheader(g); @@ -424,6 +429,9 @@ runtime·dopanic(int32 unused) runtime·lock(&deadlock); runtime·lock(&deadlock); } + + if(crash) + runtime·crash(); runtime·exit(2); } |