summaryrefslogtreecommitdiffstats
path: root/include/jemalloc/internal/ctl.h
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2012-10-09 21:46:22 (GMT)
committerJason Evans <je@fb.com>2012-10-09 22:21:46 (GMT)
commit20f1fc95adb35ea63dc61f47f2b0ffbd37d39f32 (patch)
tree9c61145b466c8f413b4f98247f17d8509e6ed8ea /include/jemalloc/internal/ctl.h
parent7de92767c20cb72c94609b9c78985526fb84a679 (diff)
downloadjemalloc-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/ctl.h')
-rw-r--r--include/jemalloc/internal/ctl.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/jemalloc/internal/ctl.h b/include/jemalloc/internal/ctl.h
index adf3827..1d0c76a 100644
--- a/include/jemalloc/internal/ctl.h
+++ b/include/jemalloc/internal/ctl.h
@@ -75,6 +75,9 @@ int ctl_nametomib(const char *name, size_t *mibp, size_t *miblenp);
int ctl_bymib(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
void *newp, size_t newlen);
bool ctl_boot(void);
+void ctl_prefork(void);
+void ctl_postfork_parent(void);
+void ctl_postfork_child(void);
#define xmallctl(name, oldp, oldlenp, newp, newlen) do { \
if (je_mallctl(name, oldp, oldlenp, newp, newlen) \