mirror of
https://github.com/gperftools/gperftools
synced 2025-02-19 13:46:50 +00:00
prevent potential corruption of errno in thread lister
See https://github.com/gperftools/gperftools/issues/500#issuecomment-133814659 for explanations. We of course evolved quite a bit since that comment, but general issue still applies.
This commit is contained in:
parent
2b5743ffa6
commit
c44e44cecb
@ -42,6 +42,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <limits.h>
|
||||
#include <sched.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
@ -648,6 +649,14 @@ int TCMalloc_ListAllProcessThreads(void *parameter,
|
||||
}
|
||||
need_sigprocmask = 1;
|
||||
|
||||
// make sure all functions used by parent from local_clone to after
|
||||
// waitpid have plt entries fully initialized. We cannot afford
|
||||
// dynamic linker running relocations and messing with errno (see
|
||||
// comment just below)
|
||||
(void)prctl(PR_GET_PDEATHSIG, 0);
|
||||
(void)close(-1);
|
||||
(void)waitpid(INT_MIN, nullptr, 0);
|
||||
|
||||
/* After cloning, both the parent and the child share the same
|
||||
* instance of errno. We deal with this by being very
|
||||
* careful. Specifically, child immediately calls into sem_wait
|
||||
|
Loading…
Reference in New Issue
Block a user