File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -339,12 +339,18 @@ void jl_gc_run_all_finalizers(jl_task_t *ct)
339339 jl_ptls_t * gc_all_tls_states ;
340340 gc_n_threads = jl_atomic_load_acquire (& jl_n_threads );
341341 gc_all_tls_states = jl_atomic_load_relaxed (& jl_all_tls_states );
342+ // this is called from `jl_atexit_hook`; threads could still be running
343+ // so we have to guard the finalizers' lists
344+ JL_LOCK_NOGC (& finalizers_lock );
342345 schedule_all_finalizers (& finalizer_list_marked );
343346 for (int i = 0 ; i < gc_n_threads ; i ++ ) {
344347 jl_ptls_t ptls2 = gc_all_tls_states [i ];
345348 if (ptls2 != NULL )
346349 schedule_all_finalizers (& ptls2 -> finalizers );
347350 }
351+ // this is called from `jl_atexit_hook`; threads could still be running
352+ // so we have to guard the finalizers' lists
353+ JL_LOCK_NOGC (& finalizers_lock );
348354 gc_n_threads = 0 ;
349355 gc_all_tls_states = NULL ;
350356 run_finalizers (ct );
You can’t perform that action at this time.
0 commit comments