diff --git a/src/gc-alloc-profiler.cpp b/src/gc-alloc-profiler.cpp index 0ff387b8706208..12a88c9ec5b8f3 100644 --- a/src/gc-alloc-profiler.cpp +++ b/src/gc-alloc-profiler.cpp @@ -50,12 +50,10 @@ jl_combined_results g_combined_results; // Will live forever. jl_raw_backtrace_t get_raw_backtrace() JL_NOTSAFEPOINT { // We first record the backtrace onto a MAX-sized buffer, so that we don't have to - // allocate the buffer until we know the size. To ensure thread-safety, we *re-use the - // per-thread backtrace buffer*, which is shared with Julia's exception throwing - // mechanism. This sharing is safe, because this function cannot be interleaved with - // exception throwing. + // allocate the buffer until we know the size. To ensure thread-safety, we use a + // per-thread backtrace buffer. jl_ptls_t ptls = jl_current_task->ptls; - jl_bt_element_t *shared_bt_data_buffer = ptls->bt_data; + jl_bt_element_t *shared_bt_data_buffer = ptls->profiling_bt_buffer; size_t bt_size = rec_backtrace(shared_bt_data_buffer, JL_MAX_BT_SIZE, 2); diff --git a/src/julia_threads.h b/src/julia_threads.h index 371eb512501159..22acf3aec8587a 100644 --- a/src/julia_threads.h +++ b/src/julia_threads.h @@ -246,6 +246,8 @@ typedef struct _jl_tls_states_t { // Temporary backtrace buffer. Scanned for gc roots when bt_size > 0. struct _jl_bt_element_t *bt_data; // JL_MAX_BT_SIZE + 1 elements long size_t bt_size; // Size for backtrace in transit in bt_data + // Temporary backtrace buffer used only for allocations profiler. + struct _jl_bt_element_t *profiling_bt_buffer; // Atomically set by the sender, reset by the handler. volatile _Atomic(sig_atomic_t) signal_request; // TODO: no actual reason for this to be _Atomic // Allow the sigint to be raised asynchronously