summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQi Wang <interwq@gwu.edu>2019-04-02 20:34:50 (GMT)
committerQi Wang <interwq@gmail.com>2019-04-02 23:53:00 (GMT)
commit978a7a21ae5fe8e5367732b2dba9f92742aef9f1 (patch)
tree85ebb8f66bb94a28501dc930f2c0b9f59915e68b
parent6fe11633b066d74bdbb0f037a373af6e12a8b6c2 (diff)
downloadjemalloc-978a7a21ae5fe8e5367732b2dba9f92742aef9f1.zip
jemalloc-978a7a21ae5fe8e5367732b2dba9f92742aef9f1.tar.gz
jemalloc-978a7a21ae5fe8e5367732b2dba9f92742aef9f1.tar.bz2
Use iallocztm instead of ialloc in prof_log functions.
Explicitly use iallocztm for internal allocations. ialloc could trigger arena creation, which may cause lock order reversal (narenas_mtx and log_mtx).
-rw-r--r--src/prof.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/prof.c b/src/prof.c
index 296de52..4d7d65d 100644
--- a/src/prof.c
+++ b/src/prof.c
@@ -376,7 +376,8 @@ prof_log_bt_index(tsd_t *tsd, prof_bt_t *bt) {
size_t sz = offsetof(prof_bt_node_t, vec) +
(bt->len * sizeof(void *));
prof_bt_node_t *new_node = (prof_bt_node_t *)
- ialloc(tsd, sz, sz_size2index(sz), false, true);
+ iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL,
+ true, arena_get(TSDN_NULL, 0, true), true);
if (log_bt_first == NULL) {
log_bt_first = new_node;
log_bt_last = new_node;
@@ -416,7 +417,8 @@ prof_log_thr_index(tsd_t *tsd, uint64_t thr_uid, const char *name) {
(void **)(&node), NULL)) {
size_t sz = offsetof(prof_thr_node_t, name) + strlen(name) + 1;
prof_thr_node_t *new_node = (prof_thr_node_t *)
- ialloc(tsd, sz, sz_size2index(sz), false, true);
+ iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL,
+ true, arena_get(TSDN_NULL, 0, true), true);
if (log_thr_first == NULL) {
log_thr_first = new_node;
log_thr_last = new_node;
@@ -474,10 +476,11 @@ prof_try_log(tsd_t *tsd, const void *ptr, size_t usize, prof_tctx_t *tctx) {
nstime_t free_time = NSTIME_ZERO_INITIALIZER;
nstime_update(&free_time);
+ size_t sz = sizeof(prof_alloc_node_t);
prof_alloc_node_t *new_node = (prof_alloc_node_t *)
- ialloc(tsd, sizeof(prof_alloc_node_t),
- sz_size2index(sizeof(prof_alloc_node_t)), false, true);
-
+ iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL, true,
+ arena_get(TSDN_NULL, 0, true), true);
+
const char *prod_thr_name = (tctx->tdata->thread_name == NULL)?
"" : tctx->tdata->thread_name;
const char *cons_thr_name = prof_thread_name_get(tsd);