Commit a026d0fc authored by Albert Strasheim's avatar Albert Strasheim Committed by Russ Cox

runtime/cgo: check for errors from pthread_create

R=rsc, iant, dvyukov
CC=golang-dev
https://golang.org/cl/4643057
parent 660b2298
...@@ -222,12 +222,21 @@ addpid(int pid, int force) ...@@ -222,12 +222,21 @@ addpid(int pid, int force)
// The excthread reads that port and signals // The excthread reads that port and signals
// us if we are waiting on that thread. // us if we are waiting on that thread.
pthread_t p; pthread_t p;
int err;
excport = mach_reply_port(); excport = mach_reply_port();
pthread_mutex_init(&mu, nil); pthread_mutex_init(&mu, nil);
pthread_cond_init(&cond, nil); pthread_cond_init(&cond, nil);
pthread_create(&p, nil, excthread, nil); err = pthread_create(&p, nil, excthread, nil);
pthread_create(&p, nil, waitthread, (void*)(uintptr)pid); 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; first = 0;
} }
......
...@@ -113,11 +113,16 @@ libcgo_sys_thread_start(ThreadStart *ts) ...@@ -113,11 +113,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr; pthread_attr_t attr;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err;
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = 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* static void*
......
...@@ -83,11 +83,16 @@ libcgo_sys_thread_start(ThreadStart *ts) ...@@ -83,11 +83,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr; pthread_attr_t attr;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err;
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = 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* static void*
......
...@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts) ...@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr; pthread_attr_t attr;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err;
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = 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* static void*
......
...@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts) ...@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr; pthread_attr_t attr;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err;
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = 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* static void*
......
...@@ -21,6 +21,7 @@ libcgo_sys_thread_start(ThreadStart *ts) ...@@ -21,6 +21,7 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr; pthread_attr_t attr;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err;
// Not sure why the memset is necessary here, // Not sure why the memset is necessary here,
// but without it, we get a bogus stack size // but without it, we get a bogus stack size
...@@ -30,7 +31,11 @@ libcgo_sys_thread_start(ThreadStart *ts) ...@@ -30,7 +31,11 @@ libcgo_sys_thread_start(ThreadStart *ts)
size = 0; size = 0;
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = 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* static void*
......
...@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts) ...@@ -20,11 +20,16 @@ libcgo_sys_thread_start(ThreadStart *ts)
pthread_attr_t attr; pthread_attr_t attr;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err;
pthread_attr_init(&attr); pthread_attr_init(&attr);
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = 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* static 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