Skip to content

Commit 309ca96

Browse files
d-nettoRAI CI (GitHub Action Automation)
authored andcommitted
bugfix: load jl_n_threads in jl_gc_pool_live_bytes (JuliaLang#52034)
Otherwise we may just observe `gc_n_threads = 0` (`jl_gc_collect` sets it to 0 in the very end of its body) and this function becomes a no-op.
1 parent 3436405 commit 309ca96

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/gc.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,9 +3261,11 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
32613261

32623262
JL_DLLEXPORT int64_t jl_gc_pool_live_bytes(void)
32633263
{
3264+
int n_threads = jl_atomic_load_acquire(&jl_n_threads);
3265+
jl_ptls_t *all_tls_states = jl_atomic_load_relaxed(&jl_all_tls_states);
32643266
int64_t pool_live_bytes = 0;
3265-
for (int i = 0; i < gc_n_threads; i++) {
3266-
jl_ptls_t ptls2 = gc_all_tls_states[i];
3267+
for (int i = 0; i < n_threads; i++) {
3268+
jl_ptls_t ptls2 = all_tls_states[i];
32673269
if (ptls2 != NULL) {
32683270
pool_live_bytes += jl_atomic_load_relaxed(&ptls2->gc_num.pool_live_bytes);
32693271
}

0 commit comments

Comments
 (0)