diff options
| author | Michael Stapelberg <stapelberg@debian.org> | 2013-05-14 18:39:35 +0200 | 
|---|---|---|
| committer | Michael Stapelberg <michael@stapelberg.de> | 2013-05-14 18:39:35 +0200 | 
| commit | efcc50dfdc94c82ee0292bf71992ecb7c0123061 (patch) | |
| tree | 17dca99d1dc7fc4e9fe49c2cf6a99d337d4c039f /src/pkg/runtime/panic.c | |
| parent | 04b08da9af0c450d645ab7389d1467308cfc2db8 (diff) | |
| download | golang-efcc50dfdc94c82ee0292bf71992ecb7c0123061.tar.gz | |
Imported Upstream version 1.1upstream/1.1
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);  } | 
