File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -472,6 +472,7 @@ static int thread0_exit_signo = 0;
472472static void JL_NORETURN jl_exit_thread0_cb (void )
473473{
474474CFI_NORETURN
475+ jl_atomic_fetch_add (& jl_gc_disable_counter , -1 );
475476 jl_critical_error (thread0_exit_signo , 0 , NULL , jl_current_task );
476477 jl_atexit_hook (128 );
477478 jl_raise (thread0_exit_signo );
@@ -963,6 +964,12 @@ static void *signal_listener(void *arg)
963964//#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309L && !HAVE_KEVENT
964965// si_code = info.si_code;
965966//#endif
967+ // Let's forbid threads from running GC while we're trying to exit,
968+ // also let's make sure we're not in the middle of GC.
969+ jl_atomic_fetch_add (& jl_gc_disable_counter , 1 );
970+ while (jl_atomic_load_acquire (& jl_gc_running )) {
971+ jl_cpu_pause ();
972+ }
966973 jl_exit_thread0 (sig , bt_data , bt_size );
967974 }
968975 else if (critical ) {
You can’t perform that action at this time.
0 commit comments