Skip to content

Commit db04c0e

Browse files
vilterpLilithHafner
authored andcommitted
alloc profiler: fix analyzegc error (JuliaLang#43875)
1 parent 545336f commit db04c0e

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/gc-alloc-profiler.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jl_combined_results g_combined_results; // Will live forever.
4646

4747
// === stack stuff ===
4848

49-
jl_raw_backtrace_t get_raw_backtrace() {
49+
jl_raw_backtrace_t get_raw_backtrace() JL_NOTSAFEPOINT {
5050
// A single large buffer to record backtraces onto
5151
static jl_bt_element_t static_bt_data[JL_MAX_BT_SIZE];
5252

@@ -120,7 +120,8 @@ JL_DLLEXPORT void jl_free_alloc_profile() {
120120

121121
void _maybe_record_alloc_to_profile(jl_value_t *val, size_t size) JL_NOTSAFEPOINT {
122122
auto& global_profile = g_alloc_profile;
123-
auto& profile = global_profile.per_thread_profiles[jl_threadid()];
123+
auto thread_id = jl_atomic_load_relaxed(&jl_current_task->tid);
124+
auto& profile = global_profile.per_thread_profiles[thread_id];
124125

125126
auto sample_val = double(rand()) / double(RAND_MAX);
126127
auto should_record = sample_val <= global_profile.sample_rate;

0 commit comments

Comments
 (0)