From 3c471149910d79745b50389c436f0ed2973e0d91 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 18 Dec 2023 16:37:52 -0500 Subject: [PATCH] Unmask signal before re-raising fatal signal On Linux, while the signal handler runs, that signal is masked, so in the rb_bug_for_fatal_signal() code path we didn't get the default signal action as intended. See signal(7). It worked fine on macOS, though. Before: $ ./miniruby -e 'Process.kill :SIGSEGV, Process.pid' Aborted (core dumped) After: $ ./miniruby -e 'Process.kill :SIGSEGV, Process.pid' Segmentation fault (core dumped) Follow-up for 1ac0afab4da "rb_bug_for_fatal_signal: exit with the right signal". --- signal.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/signal.c b/signal.c index a4822cf6bcafee..35ec892f2f711d 100644 --- a/signal.c +++ b/signal.c @@ -403,6 +403,9 @@ interrupt_init(int argc, VALUE *argv, VALUE self) } void rb_malloc_info_show_results(void); /* gc.c */ +#ifdef POSIX_SIGNAL +static void reset_sigmask(int sig); +#endif void ruby_default_signal(int sig) @@ -413,6 +416,9 @@ ruby_default_signal(int sig) rb_malloc_info_show_results(); signal(sig, SIG_DFL); +#ifdef POSIX_SIGNAL + reset_sigmask(sig); +#endif raise(sig); }