From 891cbd66a411725d7300a28b1a95619c2902f0eb Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Wed, 9 Oct 2019 23:13:59 +0900 Subject: signal.c: save the original sighandlers for fatal signals On Android, a signal handler that is not SIG_DFL is set by default for SIGSEGV. Ruby's install_sighandler inserts Ruby's handler only when the signal has no handler, so it does not insert Ruby's SEGV report handler, which caused some test failures. This changeset forces to install Ruby's handler for some fatal signals (sigbus, sigsegv, and sigill). They keep the original handlers, and call them when the interpreter receives the signals. --- error.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'error.c') diff --git a/error.c b/error.c index 56ea9ae084..f8d2545fa6 100644 --- a/error.c +++ b/error.c @@ -599,7 +599,7 @@ rb_bug(const char *fmt, ...) } void -rb_bug_for_fatal_signal(const void *ctx, const char *fmt, ...) +rb_bug_for_fatal_signal(RETSIGTYPE (*default_sighandler)(int), int sig, const void *ctx, const char *fmt, ...) { const char *file = NULL; int line = 0; @@ -610,6 +610,8 @@ rb_bug_for_fatal_signal(const void *ctx, const char *fmt, ...) report_bug(file, line, fmt, ctx); + if (default_sighandler) default_sighandler(sig); + die(); } -- cgit v1.2.3