]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/cgo: check for errors from pthread_create
authorAlbert Strasheim <fullung@gmail.com>
Tue, 28 Jun 2011 16:04:50 +0000 (12:04 -0400)
committerRuss Cox <rsc@golang.org>
Tue, 28 Jun 2011 16:04:50 +0000 (12:04 -0400)
R=rsc, iant, dvyukov
CC=golang-dev
https://golang.org/cl/4643057

src/libmach/darwin.c
src/pkg/runtime/cgo/darwin_386.c
src/pkg/runtime/cgo/darwin_amd64.c
src/pkg/runtime/cgo/freebsd_386.c
src/pkg/runtime/cgo/freebsd_amd64.c
src/pkg/runtime/cgo/linux_386.c
src/pkg/runtime/cgo/linux_amd64.c

index c443a4fbab29de363f89bdf863e1610ada8bfdaf..63abde3136e66931edfc9ada53dcecf8da4b40bd 100644 (file)
@@ -222,12 +222,21 @@ addpid(int pid, int force)
                // The excthread reads that port and signals
                // us if we are waiting on that thread.
                pthread_t p;
+               int err;
 
                excport = mach_reply_port();
                pthread_mutex_init(&mu, nil);
                pthread_cond_init(&cond, nil);
-               pthread_create(&p, nil, excthread, nil);
-               pthread_create(&p, nil, waitthread, (void*)(uintptr)pid);
+               err = pthread_create(&p, nil, excthread, nil);
+               if (err != 0) {
+                       fprint(2, "pthread_create failed: %s\n", strerror(err));
+                       abort();
+               }
+               err = pthread_create(&p, nil, waitthread, (void*)(uintptr)pid);
+               if (err != 0) {
+                       fprint(2, "pthread_create failed: %s\n", strerror(err));
+                       abort();
+               }
                first = 0;
        }
 
index 13184f3217c45b8c2d0163dd32d7d331cedebb44..21c13657591bdf923ea9c4bae3acb52de68c441a 100644 (file)
@@ -113,11 +113,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
        pthread_attr_t attr;
        pthread_t p;
        size_t size;
+       int err;
 
        pthread_attr_init(&attr);
        pthread_attr_getstacksize(&attr, &size);
        ts->g->stackguard = size;
-       pthread_create(&p, &attr, threadentry, ts);
+       err = pthread_create(&p, &attr, threadentry, ts);
+       if (err != 0) {
+               fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(error));
+               abort();
+       }
 }
 
 static void*
index 38cd80a6f93374da2213250b7db3aa490e35f28e..3471044c014ff6b509ed9ef4a2e7e53aaee08953 100644 (file)
@@ -83,11 +83,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
        pthread_attr_t attr;
        pthread_t p;
        size_t size;
+       int err;
 
        pthread_attr_init(&attr);
        pthread_attr_getstacksize(&attr, &size);
        ts->g->stackguard = size;
-       pthread_create(&p, &attr, threadentry, ts);
+       err = pthread_create(&p, &attr, threadentry, ts);
+       if (err != 0) {
+               fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
+               abort();
+       }
 }
 
 static void*
index d08e1dee8cb6e250df9fb93b998040f2865b7d3e..ae53201b41e337ec0728a0f4f7dabad5a494aae8 100644 (file)
@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
        pthread_attr_t attr;
        pthread_t p;
        size_t size;
+       int err;
 
        pthread_attr_init(&attr);
        pthread_attr_getstacksize(&attr, &size);
        ts->g->stackguard = size;
-       pthread_create(&p, &attr, threadentry, ts);
+       err = pthread_create(&p, &attr, threadentry, ts);
+       if (err != 0) {
+               fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
+               abort();
+       }
 }
 
 static void*
index fe6ce391f3f9c6607105d3f58846474305f55ade..5afc1dfeafbaadb90da0aa11719163655c894067 100644 (file)
@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
        pthread_attr_t attr;
        pthread_t p;
        size_t size;
+       int err;
 
        pthread_attr_init(&attr);
        pthread_attr_getstacksize(&attr, &size);
        ts->g->stackguard = size;
-       pthread_create(&p, &attr, threadentry, ts);
+       err = pthread_create(&p, &attr, threadentry, ts);
+       if (err != 0) {
+               fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
+               abort();
+       }
 }
 
 static void*
index 00322d4b7e7b9583e7a9f7a1c81149d758698541..e9df5ffdccbc2fe6e9e6319daf290a4b48ad2b0c 100644 (file)
@@ -21,6 +21,7 @@ libcgo_sys_thread_start(ThreadStart *ts)
        pthread_attr_t attr;
        pthread_t p;
        size_t size;
+       int err;
 
        // Not sure why the memset is necessary here,
        // but without it, we get a bogus stack size
@@ -30,7 +31,11 @@ libcgo_sys_thread_start(ThreadStart *ts)
        size = 0;
        pthread_attr_getstacksize(&attr, &size);
        ts->g->stackguard = size;
-       pthread_create(&p, &attr, threadentry, ts);
+       err = pthread_create(&p, &attr, threadentry, ts);
+       if (err != 0) {
+               fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
+               abort();
+       }
 }
 
 static void*
index e77c5ddfed8b17594979a69cd56876b070f23779..d9b8b37061020e2503ee2005aa66760f9e32a11d 100644 (file)
@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
        pthread_attr_t attr;
        pthread_t p;
        size_t size;
+       int err;
 
        pthread_attr_init(&attr);
        pthread_attr_getstacksize(&attr, &size);
        ts->g->stackguard = size;
-       pthread_create(&p, &attr, threadentry, ts);
+       err = pthread_create(&p, &attr, threadentry, ts);
+       if (err != 0) {
+               fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
+               abort();
+       }
 }
 
 static void*