mirror of
https://github.com/klzgrad/naiveproxy.git
synced 2025-02-23 18:33:22 +03:00
musl: allocator: Avoid deadlock in pthread_atfork
Musl 1.2.3 and before call malloc() in pthread_atfork(), which may result in a deadlock.
This commit is contained in:
parent
c087e6f6d5
commit
ce8c22e607
@ -59,7 +59,9 @@ thread_local bool g_is_main_thread = true;
|
||||
class InitAtFork {
|
||||
public:
|
||||
InitAtFork() {
|
||||
#if !defined(__MUSL__)
|
||||
pthread_atfork(nullptr, nullptr, internal::InvalidateTidCache);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -297,7 +297,11 @@ void PartitionAllocMallocInitOnce() {
|
||||
return;
|
||||
}
|
||||
|
||||
#if PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
|
||||
#if defined(__MUSL__)
|
||||
static_cast<void>(BeforeForkInParent);
|
||||
static_cast<void>(AfterForkInParent);
|
||||
static_cast<void>(AfterForkInChild);
|
||||
#elif PA_BUILDFLAG(IS_LINUX) || PA_BUILDFLAG(IS_CHROMEOS)
|
||||
// When fork() is called, only the current thread continues to execute in the
|
||||
// child process. If the lock is held, but *not* by this thread when fork() is
|
||||
// called, we have a deadlock.
|
||||
|
Loading…
x
Reference in New Issue
Block a user