From 4f1d1116ec1171cecf45381dbf08334d8c5310fc Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Mon, 19 May 2025 15:59:08 +0530 Subject: [PATCH 1/3] Update init.c --- src/init.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/init.c b/src/init.c index 5a8a3eaf5ccf2..db52daf288761 100644 --- a/src/init.c +++ b/src/init.c @@ -557,6 +557,12 @@ static void restore_fp_env(void) if (jl_set_zero_subnormals(0) || jl_set_default_nans(0)) { jl_error("Failed to configure floating point environment"); } + if (!jl_options.handle_signals && jl_n_threads > 1) { + jl_error("Cannot use `--handle-signals=no` with multiple threads (JULIA_NUM_THREADS > 1).\n" + "This will cause segmentation faults due to GC safepoint failures.\n" + "Remove `--handle-signals=no` or set JULIA_NUM_THREADS=1.\n" + "See: https://github.com/JuliaLang/julia/issues/50278"); + } } static NOINLINE void _finish_jl_init_(jl_image_buf_t sysimage, jl_ptls_t ptls, jl_task_t *ct) { From bccddb05b23957de87533ec70b1475f0e4beef94 Mon Sep 17 00:00:00 2001 From: ArnavKapoor Date: Tue, 20 May 2025 08:56:31 +0530 Subject: [PATCH 2/3] Fix: use jl_atomic_load_relaxed for jl_signal_thread for thread safety --- src/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.c b/src/init.c index db52daf288761..231d641cfeecf 100644 --- a/src/init.c +++ b/src/init.c @@ -557,7 +557,7 @@ static void restore_fp_env(void) if (jl_set_zero_subnormals(0) || jl_set_default_nans(0)) { jl_error("Failed to configure floating point environment"); } - if (!jl_options.handle_signals && jl_n_threads > 1) { + if (!jl_options.handle_signals && jl_atomic_load_relaxed(&jl_n_threads) > 1) { jl_error("Cannot use `--handle-signals=no` with multiple threads (JULIA_NUM_THREADS > 1).\n" "This will cause segmentation faults due to GC safepoint failures.\n" "Remove `--handle-signals=no` or set JULIA_NUM_THREADS=1.\n" From 137cc6825535cbd907d1b765e2a3bf500cda4a51 Mon Sep 17 00:00:00 2001 From: Arnav Kapoor Date: Thu, 22 May 2025 18:05:49 +0530 Subject: [PATCH 3/3] Update src/init.c Co-authored-by: Cody Tapscott <84105208+topolarity@users.noreply.github.com> --- src/init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init.c b/src/init.c index 231d641cfeecf..c3a20443b61f3 100644 --- a/src/init.c +++ b/src/init.c @@ -557,7 +557,7 @@ static void restore_fp_env(void) if (jl_set_zero_subnormals(0) || jl_set_default_nans(0)) { jl_error("Failed to configure floating point environment"); } - if (!jl_options.handle_signals && jl_atomic_load_relaxed(&jl_n_threads) > 1) { + if (jl_options.handle_signals == JL_OPTIONS_HANDLE_SIGNALS_OFF && jl_atomic_load_relaxed(&jl_n_threads) > 1) { jl_error("Cannot use `--handle-signals=no` with multiple threads (JULIA_NUM_THREADS > 1).\n" "This will cause segmentation faults due to GC safepoint failures.\n" "Remove `--handle-signals=no` or set JULIA_NUM_THREADS=1.\n"