Commit 2e4a0359 authored by Russ Cox's avatar Russ Cox

runtime: do not handle signals before configuring handler

There was a small window during program initialization
where a signal could come in before the handling mechanisms
were set up to handle it.  Delay the signal-handler installation
until we're ready for the signals.

Fixes #3314.

R=golang-dev, dsymonds, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/5833049
parent 7694da1f
...@@ -734,6 +734,12 @@ runtime·mstart(void) ...@@ -734,6 +734,12 @@ runtime·mstart(void)
m->g0->sched.pc = (void*)-1; // make sure it is never used m->g0->sched.pc = (void*)-1; // make sure it is never used
runtime·asminit(); runtime·asminit();
runtime·minit(); runtime·minit();
// Install signal handlers; after minit so that minit can
// prepare the thread to be able to handle the signals.
if(m == &runtime·m0)
runtime·initsig();
schedule(nil); schedule(nil);
} }
...@@ -1161,7 +1167,7 @@ runtime·malg(int32 stacksize) ...@@ -1161,7 +1167,7 @@ runtime·malg(int32 stacksize)
{ {
G *newg; G *newg;
byte *stk; byte *stk;
if(StackTop < sizeof(Stktop)) { if(StackTop < sizeof(Stktop)) {
runtime·printf("runtime: SizeofStktop=%d, should be >=%d\n", (int32)StackTop, (int32)sizeof(Stktop)); runtime·printf("runtime: SizeofStktop=%d, should be >=%d\n", (int32)StackTop, (int32)sizeof(Stktop));
runtime·throw("runtime: bad stack.h"); runtime·throw("runtime: bad stack.h");
......
...@@ -119,7 +119,7 @@ void ...@@ -119,7 +119,7 @@ void
runtime·panicstring(int8 *s) runtime·panicstring(int8 *s)
{ {
Eface err; Eface err;
if(m->gcing) { if(m->gcing) {
runtime·printf("panic: %s\n", s); runtime·printf("panic: %s\n", s);
runtime·throw("panic during gc"); runtime·throw("panic during gc");
...@@ -189,7 +189,7 @@ runtime·goargs(void) ...@@ -189,7 +189,7 @@ runtime·goargs(void)
{ {
String *s; String *s;
int32 i; int32 i;
// for windows implementation see "os" package // for windows implementation see "os" package
if(Windows) if(Windows)
return; return;
...@@ -207,7 +207,7 @@ runtime·goenvs_unix(void) ...@@ -207,7 +207,7 @@ runtime·goenvs_unix(void)
{ {
String *s; String *s;
int32 i, n; int32 i, n;
for(n=0; argv[argc+1+n] != 0; n++) for(n=0; argv[argc+1+n] != 0; n++)
; ;
...@@ -342,8 +342,6 @@ runtime·check(void) ...@@ -342,8 +342,6 @@ runtime·check(void)
runtime·throw("float32nan2"); runtime·throw("float32nan2");
if(!(i != i1)) if(!(i != i1))
runtime·throw("float32nan3"); runtime·throw("float32nan3");
runtime·initsig();
} }
void void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment