diff --git a/include/jemalloc/internal/prof_log_externs.h b/include/jemalloc/internal/prof_log_externs.h index cde651b5..c8cc5a3e 100644 --- a/include/jemalloc/internal/prof_log_externs.h +++ b/include/jemalloc/internal/prof_log_externs.h @@ -3,6 +3,8 @@ #include "jemalloc/internal/mutex.h" +extern malloc_mutex_t log_mtx; + void prof_try_log(tsd_t *tsd, size_t usize, prof_info_t *prof_info); bool prof_log_init(tsd_t *tsdn); #ifdef JEMALLOC_JET diff --git a/src/prof.c b/src/prof.c index 58839bc4..f35bba99 100644 --- a/src/prof.c +++ b/src/prof.c @@ -1119,6 +1119,7 @@ prof_prefork0(tsdn_t *tsdn) { for (i = 0; i < PROF_NTDATA_LOCKS; i++) { malloc_mutex_prefork(tsdn, &tdata_locks[i]); } + malloc_mutex_prefork(tsdn, &log_mtx); for (i = 0; i < PROF_NCTX_LOCKS; i++) { malloc_mutex_prefork(tsdn, &gctx_locks[i]); } @@ -1150,6 +1151,7 @@ prof_postfork_parent(tsdn_t *tsdn) { for (i = 0; i < PROF_NCTX_LOCKS; i++) { malloc_mutex_postfork_parent(tsdn, &gctx_locks[i]); } + malloc_mutex_postfork_parent(tsdn, &log_mtx); for (i = 0; i < PROF_NTDATA_LOCKS; i++) { malloc_mutex_postfork_parent(tsdn, &tdata_locks[i]); } @@ -1172,6 +1174,7 @@ prof_postfork_child(tsdn_t *tsdn) { for (i = 0; i < PROF_NCTX_LOCKS; i++) { malloc_mutex_postfork_child(tsdn, &gctx_locks[i]); } + malloc_mutex_postfork_child(tsdn, &log_mtx); for (i = 0; i < PROF_NTDATA_LOCKS; i++) { malloc_mutex_postfork_child(tsdn, &tdata_locks[i]); } diff --git a/src/prof_log.c b/src/prof_log.c index 6ac81e07..9411b98c 100644 --- a/src/prof_log.c +++ b/src/prof_log.c @@ -104,7 +104,7 @@ static prof_alloc_node_t *log_alloc_first = NULL; static prof_alloc_node_t *log_alloc_last = NULL; /* Protects the prof_logging_state and any log_{...} variable. */ -static malloc_mutex_t log_mtx; +malloc_mutex_t log_mtx; /******************************************************************************/ /*