File tree Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Expand file tree Collapse file tree 1 file changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -526,12 +526,17 @@ void jl_gc_run_all_finalizers(jl_task_t *ct)
526
526
jl_ptls_t * gc_all_tls_states ;
527
527
gc_n_threads = jl_atomic_load_acquire (& jl_n_threads );
528
528
gc_all_tls_states = jl_atomic_load_relaxed (& jl_all_tls_states );
529
+ // this is called from `jl_atexit_hook`; threads could still be running
530
+ // so we have to guard the finalizers' lists
531
+ JL_LOCK_NOGC (& finalizers_lock );
529
532
schedule_all_finalizers (& finalizer_list_marked );
530
533
for (int i = 0 ; i < gc_n_threads ; i ++ ) {
531
534
jl_ptls_t ptls2 = gc_all_tls_states [i ];
532
535
if (ptls2 != NULL )
533
536
schedule_all_finalizers (& ptls2 -> finalizers );
534
537
}
538
+ // unlock here because `run_finalizers` locks this
539
+ JL_UNLOCK_NOGC (& finalizers_lock );
535
540
gc_n_threads = 0 ;
536
541
gc_all_tls_states = NULL ;
537
542
run_finalizers (ct );
You can’t perform that action at this time.
0 commit comments