diff --git a/jemalloc/src/arena.c b/jemalloc/src/arena.c index e4142267..ee859fcb 100644 --- a/jemalloc/src/arena.c +++ b/jemalloc/src/arena.c @@ -254,7 +254,6 @@ arena_run_reg_alloc(arena_run_t *run, arena_bin_t *bin) run->nfree--; ret = run->avail; if (ret != NULL) { - run->avail = *(void **)ret; /* Double free can cause assertion failure.*/ assert(ret != NULL); /* Write-after free can cause assertion failure. */ @@ -264,6 +263,7 @@ arena_run_reg_alloc(arena_run_t *run, arena_bin_t *bin) assert(((uintptr_t)ret - ((uintptr_t)run + (uintptr_t)bin->reg0_offset)) % (uintptr_t)bin->reg_size == 0); + run->avail = *(void **)ret; return (ret); } ret = run->next; diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c index bf2ace39..b36590dd 100644 --- a/jemalloc/src/jemalloc.c +++ b/jemalloc/src/jemalloc.c @@ -324,6 +324,7 @@ malloc_init_hard(void) CPU_SPINWAIT; malloc_mutex_lock(&init_lock); } while (malloc_initialized == false); + malloc_mutex_unlock(&init_lock); return (false); } diff --git a/jemalloc/src/prof.c b/jemalloc/src/prof.c index 88e8f44a..6d6910ed 100644 --- a/jemalloc/src/prof.c +++ b/jemalloc/src/prof.c @@ -239,16 +239,15 @@ prof_backtrace(prof_bt_t *bt, unsigned nignore, unsigned max) } /* - * Iterate over stack frames until there are no more. Heap-allocate - * and iteratively grow a larger bt if necessary. + * Iterate over stack frames until there are no more, or until no space + * remains in bt. */ for (i = 0; i < max; i++) { unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *)&bt->vec[i]); + bt->len++; err = unw_step(&cursor); - if (err <= 0) { - bt->len = i; + if (err <= 0) break; - } } } #else