mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-04-20 06:20:20 +02:00
handle pthread_atfork calling into malloc
This results in compatibility with the malloc replacement support added in musl 1.1.20.
This commit is contained in:
parent
1be74ec40d
commit
684e63a878
1 changed files with 5 additions and 4 deletions
9
malloc.c
9
malloc.c
|
@ -609,10 +609,6 @@ COLD static void init_slow_path(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_atfork(full_lock, full_unlock, post_fork_child)) {
|
|
||||||
fatal_error("pthread_atfork failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sysconf(_SC_PAGESIZE) != PAGE_SIZE) {
|
if (sysconf(_SC_PAGESIZE) != PAGE_SIZE) {
|
||||||
fatal_error("page size mismatch");
|
fatal_error("page size mismatch");
|
||||||
}
|
}
|
||||||
|
@ -673,6 +669,11 @@ COLD static void init_slow_path(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pthread_mutex_unlock(&mutex);
|
pthread_mutex_unlock(&mutex);
|
||||||
|
|
||||||
|
// may allocate, so wait until the allocator is initialized to avoid deadlocking
|
||||||
|
if (pthread_atfork(full_lock, full_unlock, post_fork_child)) {
|
||||||
|
fatal_error("pthread_atfork failed");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void init(void) {
|
static inline void init(void) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue