Try to avoid races in underlying C library
during threadexitsall.
This commit is contained in:
parent
5f4529e351
commit
9689b580bd
2 changed files with 28 additions and 0 deletions
|
|
@ -285,6 +285,20 @@ threadexitsall(char *msg)
|
||||||
int i, npid, mypid;
|
int i, npid, mypid;
|
||||||
Proc *p;
|
Proc *p;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only one guy, ever, gets to run this.
|
||||||
|
* If two guys do it, inevitably they end up
|
||||||
|
* tripping over each other in the underlying
|
||||||
|
* C library exit() implementation, which is
|
||||||
|
* trying to run the atexit handlers and apparently
|
||||||
|
* not thread safe. This has been observed on
|
||||||
|
* both Linux and OpenBSD. Sigh.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
static Lock onelock;
|
||||||
|
lock(&onelock);
|
||||||
|
}
|
||||||
|
|
||||||
if(msg == nil)
|
if(msg == nil)
|
||||||
msg = "";
|
msg = "";
|
||||||
mypid = getpid();
|
mypid = getpid();
|
||||||
|
|
|
||||||
|
|
@ -311,6 +311,20 @@ threadexitsall(char *msg)
|
||||||
int i, npid, mypid;
|
int i, npid, mypid;
|
||||||
Proc *p;
|
Proc *p;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only one guy, ever, gets to run this.
|
||||||
|
* If two guys do it, inevitably they end up
|
||||||
|
* tripping over each other in the underlying
|
||||||
|
* C library exit() implementation, which is
|
||||||
|
* trying to run the atexit handlers and apparently
|
||||||
|
* not thread safe. This has been observed on
|
||||||
|
* both Linux and OpenBSD. Sigh.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
static Lock onelock;
|
||||||
|
lock(&onelock);
|
||||||
|
}
|
||||||
|
|
||||||
if(msg == nil)
|
if(msg == nil)
|
||||||
msg = "";
|
msg = "";
|
||||||
mypid = getpid();
|
mypid = getpid();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue