diff --git a/src/gc-alloc-profiler.cpp b/src/gc-alloc-profiler.cpp index 4846d7f7f7fb1..6d0af5cb9c1b6 100644 --- a/src/gc-alloc-profiler.cpp +++ b/src/gc-alloc-profiler.cpp @@ -54,9 +54,11 @@ jl_raw_backtrace_t get_raw_backtrace() JL_NOTSAFEPOINT { // per-thread backtrace buffer. jl_ptls_t ptls = jl_current_task->ptls; jl_bt_element_t *shared_bt_data_buffer = ptls->profiling_bt_buffer; - if (shared_bt_data_buffer == NULL) - ptls->profiling_bt_buffer = shared_bt_data_buffer = \ - malloc_s(sizeof(jl_bt_element_t) * (JL_MAX_BT_SIZE + 1)); + if (shared_bt_data_buffer == NULL) { + size_t size = sizeof(jl_bt_element_t) * (JL_MAX_BT_SIZE + 1); + shared_bt_data_buffer = (jl_bt_element_t*) malloc_s(size); + ptls->profiling_bt_buffer = shared_bt_data_buffer; + } size_t bt_size = rec_backtrace(shared_bt_data_buffer, JL_MAX_BT_SIZE, 2);