]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: detect failed thread creation on Windows
authorAlex Brainman <alex.brainman@gmail.com>
Mon, 14 Feb 2011 22:42:25 +0000 (09:42 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Mon, 14 Feb 2011 22:42:25 +0000 (09:42 +1100)
Fixes #1495.

R=rsc
CC=golang-dev
https://golang.org/cl/4182047

src/pkg/runtime/windows/thread.c

index 525fd0980168dd71388d01aa6338ba534fa749c4..aedd24200af561e4f2239a452404e2da41caf313 100644 (file)
@@ -184,11 +184,17 @@ runtime·notesleep(Note *n)
 void
 runtime·newosproc(M *m, G *g, void *stk, void (*fn)(void))
 {
+       void *thandle;
+
        USED(stk);
        USED(g);        // assuming g = m->g0
        USED(fn);       // assuming fn = mstart
 
-       runtime·stdcall(runtime·CreateThread, 6, 0, 0, runtime·tstart_stdcall, m, 0, 0);
+       thandle = runtime·stdcall(runtime·CreateThread, 6, 0, 0, runtime·tstart_stdcall, m, 0, 0);
+       if(thandle == 0) {
+               runtime·printf("runtime: failed to create new OS thread (have %d already; errno=%d)\n", runtime·mcount(), runtime·getlasterror());
+               runtime·throw("runtime.newosproc");
+       }
 }
 
 // Called to initialize a new m (including the bootstrap m).