diff options
author | Jason Evans <je@fb.com> | 2012-10-09 21:46:22 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2012-10-09 22:21:46 (GMT) |
commit | 20f1fc95adb35ea63dc61f47f2b0ffbd37d39f32 (patch) | |
tree | 9c61145b466c8f413b4f98247f17d8509e6ed8ea /include/jemalloc/internal/chunk.h | |
parent | 7de92767c20cb72c94609b9c78985526fb84a679 (diff) | |
download | jemalloc-20f1fc95adb35ea63dc61f47f2b0ffbd37d39f32.zip jemalloc-20f1fc95adb35ea63dc61f47f2b0ffbd37d39f32.tar.gz jemalloc-20f1fc95adb35ea63dc61f47f2b0ffbd37d39f32.tar.bz2 |
Fix fork(2)-related deadlocks.
Add a library constructor for jemalloc that initializes the allocator.
This fixes a race that could occur if threads were created by the main
thread prior to any memory allocation, followed by fork(2), and then
memory allocation in the child process.
Fix the prefork/postfork functions to acquire/release the ctl, prof, and
rtree mutexes. This fixes various fork() child process deadlocks, but
one possible deadlock remains (intentionally) unaddressed: prof
backtracing can acquire runtime library mutexes, so deadlock is still
possible if heap profiling is enabled during fork(). This deadlock is
known to be a real issue in at least the case of libgcc-based
backtracing.
Reported by tfengjun.
Diffstat (limited to 'include/jemalloc/internal/chunk.h')
-rw-r--r-- | include/jemalloc/internal/chunk.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/include/jemalloc/internal/chunk.h b/include/jemalloc/internal/chunk.h index 8fb1fe6..c3c3e9c 100644 --- a/include/jemalloc/internal/chunk.h +++ b/include/jemalloc/internal/chunk.h @@ -45,6 +45,9 @@ extern size_t arena_maxclass; /* Max size class for arenas. */ void *chunk_alloc(size_t size, size_t alignment, bool base, bool *zero); void chunk_dealloc(void *chunk, size_t size, bool unmap); bool chunk_boot(void); +void chunk_prefork(void); +void chunk_postfork_parent(void); +void chunk_postfork_child(void); #endif /* JEMALLOC_H_EXTERNS */ /******************************************************************************/ |