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 @@ -638,12 +638,17 @@ void jl_gc_run_all_finalizers(jl_task_t *ct)
638
638
jl_ptls_t * gc_all_tls_states ;
639
639
gc_n_threads = jl_atomic_load_acquire (& jl_n_threads );
640
640
gc_all_tls_states = jl_atomic_load_relaxed (& jl_all_tls_states );
641
+ // this is called from `jl_atexit_hook`; threads could still be running
642
+ // so we have to guard the finalizers' lists
643
+ JL_LOCK_NOGC (& finalizers_lock );
641
644
schedule_all_finalizers (& finalizer_list_marked );
642
645
for (int i = 0 ; i < gc_n_threads ; i ++ ) {
643
646
jl_ptls_t ptls2 = gc_all_tls_states [i ];
644
647
if (ptls2 )
645
648
schedule_all_finalizers (& ptls2 -> finalizers );
646
649
}
650
+ // unlock here because `run_finalizers` locks this
651
+ JL_UNLOCK_NOGC (& finalizers_lock );
647
652
gc_n_threads = 0 ;
648
653
gc_all_tls_states = NULL ;
649
654
run_finalizers (ct );
You can’t perform that action at this time.
0 commit comments