Skip to content

Commit 978a7a2

Browse files
committed
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).
1 parent 6fe1163 commit 978a7a2

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/prof.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ prof_log_bt_index(tsd_t *tsd, prof_bt_t *bt) {
376376
size_t sz = offsetof(prof_bt_node_t, vec) +
377377
(bt->len * sizeof(void *));
378378
prof_bt_node_t *new_node = (prof_bt_node_t *)
379-
ialloc(tsd, sz, sz_size2index(sz), false, true);
379+
iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL,
380+
true, arena_get(TSDN_NULL, 0, true), true);
380381
if (log_bt_first == NULL) {
381382
log_bt_first = new_node;
382383
log_bt_last = new_node;
@@ -416,7 +417,8 @@ prof_log_thr_index(tsd_t *tsd, uint64_t thr_uid, const char *name) {
416417
(void **)(&node), NULL)) {
417418
size_t sz = offsetof(prof_thr_node_t, name) + strlen(name) + 1;
418419
prof_thr_node_t *new_node = (prof_thr_node_t *)
419-
ialloc(tsd, sz, sz_size2index(sz), false, true);
420+
iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL,
421+
true, arena_get(TSDN_NULL, 0, true), true);
420422
if (log_thr_first == NULL) {
421423
log_thr_first = new_node;
422424
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) {
474476
nstime_t free_time = NSTIME_ZERO_INITIALIZER;
475477
nstime_update(&free_time);
476478

479+
size_t sz = sizeof(prof_alloc_node_t);
477480
prof_alloc_node_t *new_node = (prof_alloc_node_t *)
478-
ialloc(tsd, sizeof(prof_alloc_node_t),
479-
sz_size2index(sizeof(prof_alloc_node_t)), false, true);
480-
481+
iallocztm(tsd_tsdn(tsd), sz, sz_size2index(sz), false, NULL, true,
482+
arena_get(TSDN_NULL, 0, true), true);
483+
481484
const char *prod_thr_name = (tctx->tdata->thread_name == NULL)?
482485
"" : tctx->tdata->thread_name;
483486
const char *cons_thr_name = prof_thread_name_get(tsd);

0 commit comments

Comments
 (0)