From 1206c4cd57d6ee8d561d2454ed1f9a9a38bc0345 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Mon, 11 Sep 2023 12:29:11 +0200 Subject: [PATCH 1/2] DAOS-14248 engine: strengthen signals handling Re-register DAOS handler in case original handler returns. Re-add USR1/USR2 signals to waiting set when triggered. Required-githooks: true Signed-off-by: Bruno Faccini --- src/engine/init.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/engine/init.c b/src/engine/init.c index 874fbf62ebf..617510553af 100644 --- a/src/engine/init.c +++ b/src/engine/init.c @@ -1149,7 +1149,11 @@ print_backtrace(int signo, siginfo_t *info, void *p) else fprintf(stderr, "No useful backtrace available"); - /* re-register old handler */ + /* re-register old handler + * + * XXX we may choose to forget about old handler and simply register + * signal again as SIG_DFL and raise it for corefile creation + */ rc = sigaction(signo, &old_handlers[signo], NULL); if (rc != 0) { D_ERROR("sigaction() failure registering new and reading old " @@ -1160,18 +1164,16 @@ print_backtrace(int signo, siginfo_t *info, void *p) exit(EXIT_FAILURE); } - /* XXX we may choose to forget about old handler and simply register - * signal again as SIG_DFL and raise it for corefile creation - */ if (old_handlers[signo].sa_sigaction != NULL || old_handlers[signo].sa_handler != SIG_IGN) { - /* XXX will old handler get accurate siginfo_t/ucontext_t ? - * we may prefer to call it with the same params we got ? + /* XXX will old handler get accurate/original siginfo_t/ucontext_t ? + * should we instead call it with the same params we got ? */ raise(signo); } - memset(&old_handlers[signo], 0, sizeof(struct sigaction)); + /* if old handler(s) also returns re-register myself for signo */ + daos_register_sighand(signo, print_backtrace); } int @@ -1286,6 +1288,8 @@ main(int argc, char **argv) if (sig == SIGUSR1) { D_INFO("got SIGUSR1, dumping Argobots infos and ULTs stacks\n"); dss_dump_ABT_state(abt_infos); + /* re-add SIGUSR1 to set */ + sigaddset(&set, SIGUSR1); continue; } @@ -1297,6 +1301,8 @@ main(int argc, char **argv) ABT_info_trigger_print_all_thread_stacks(abt_infos, 10.0, NULL, NULL); + /* re-add SIGUSR2 to set */ + sigaddset(&set, SIGUSR2); continue; } From bc5d9e91dc4b79ff93bfb4f73f31f477296542e9 Mon Sep 17 00:00:00 2001 From: Bruno Faccini Date: Thu, 14 Sep 2023 18:35:46 +0200 Subject: [PATCH 2/2] DAOS-14248 engine: do not re-register handler My previous change/commit was wrongly re-register DAOS signal handler. Also catch SIGTRAP. Required-githooks: true Signed-off-by: Bruno Faccini --- src/engine/init.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/engine/init.c b/src/engine/init.c index 617510553af..93c613b68e9 100644 --- a/src/engine/init.c +++ b/src/engine/init.c @@ -1153,6 +1153,9 @@ print_backtrace(int signo, siginfo_t *info, void *p) * * XXX we may choose to forget about old handler and simply register * signal again as SIG_DFL and raise it for corefile creation + * + * XXX will old handler get accurate/original siginfo_t/ucontext_t ? + * should we instead call it with the same params we got ? */ rc = sigaction(signo, &old_handlers[signo], NULL); if (rc != 0) { @@ -1164,16 +1167,8 @@ print_backtrace(int signo, siginfo_t *info, void *p) exit(EXIT_FAILURE); } - if (old_handlers[signo].sa_sigaction != NULL || - old_handlers[signo].sa_handler != SIG_IGN) { - /* XXX will old handler get accurate/original siginfo_t/ucontext_t ? - * should we instead call it with the same params we got ? - */ - raise(signo); - } - - /* if old handler(s) also returns re-register myself for signo */ - daos_register_sighand(signo, print_backtrace); + /* raise signal again for either old handler or system default action */ + raise(signo); } int @@ -1194,6 +1189,7 @@ main(int argc, char **argv) sigdelset(&set, SIGFPE); sigdelset(&set, SIGBUS); sigdelset(&set, SIGSEGV); + sigdelset(&set, SIGTRAP); /** also allow abort()/assert() to trigger */ sigdelset(&set, SIGABRT); @@ -1210,6 +1206,7 @@ main(int argc, char **argv) daos_register_sighand(SIGBUS, print_backtrace); daos_register_sighand(SIGSEGV, print_backtrace); daos_register_sighand(SIGABRT, print_backtrace); + daos_register_sighand(SIGTRAP, print_backtrace); /** server initialization */ rc = server_init(argc, argv);