Commit 699dbb60 authored by Ian Lance Taylor's avatar Ian Lance Taylor

runtime/cgo: always set signal mask before calling pthread_create

This was done correctly for most targets but was missing from
FreeBSD/ARM and Linux/ARM.

R=golang-codereviews, dave
CC=golang-codereviews
https://golang.org/cl/45180043
parent 7413e48d
...@@ -39,10 +39,14 @@ void ...@@ -39,10 +39,14 @@ void
_cgo_sys_thread_start(ThreadStart *ts) _cgo_sys_thread_start(ThreadStart *ts)
{ {
pthread_attr_t attr; pthread_attr_t attr;
sigset_t ign, oset;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err; int err;
SIGFILLSET(ign);
pthread_sigmask(SIG_SETMASK, &ign, &oset);
// 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
// out of pthread_attr_getstacksize. C'est la Linux. // out of pthread_attr_getstacksize. C'est la Linux.
...@@ -52,6 +56,9 @@ _cgo_sys_thread_start(ThreadStart *ts) ...@@ -52,6 +56,9 @@ _cgo_sys_thread_start(ThreadStart *ts)
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size; ts->g->stackguard = size;
err = pthread_create(&p, &attr, threadentry, ts); err = pthread_create(&p, &attr, threadentry, ts);
pthread_sigmask(SIG_SETMASK, &oset, nil);
if (err != 0) { if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
abort(); abort();
......
...@@ -28,10 +28,14 @@ void ...@@ -28,10 +28,14 @@ void
_cgo_sys_thread_start(ThreadStart *ts) _cgo_sys_thread_start(ThreadStart *ts)
{ {
pthread_attr_t attr; pthread_attr_t attr;
sigset_t ign, oset;
pthread_t p; pthread_t p;
size_t size; size_t size;
int err; int err;
sigfillset(&ign);
pthread_sigmask(SIG_SETMASK, &ign, &oset);
// 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
// out of pthread_attr_getstacksize. C'est la Linux. // out of pthread_attr_getstacksize. C'est la Linux.
...@@ -41,6 +45,9 @@ _cgo_sys_thread_start(ThreadStart *ts) ...@@ -41,6 +45,9 @@ _cgo_sys_thread_start(ThreadStart *ts)
pthread_attr_getstacksize(&attr, &size); pthread_attr_getstacksize(&attr, &size);
ts->g->stackguard = size; ts->g->stackguard = size;
err = pthread_create(&p, &attr, threadentry, ts); err = pthread_create(&p, &attr, threadentry, ts);
pthread_sigmask(SIG_SETMASK, &oset, nil);
if (err != 0) { if (err != 0) {
fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err)); fprintf(stderr, "runtime/cgo: pthread_create failed: %s\n", strerror(err));
abort(); abort();
......
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