From 0b244f67df26c613ed98e8036ee65aa0c8990892 Mon Sep 17 00:00:00 2001 From: Dmitrii Kuvaiskii Date: Sun, 7 Jul 2019 23:46:00 -0700 Subject: [PATCH] [LibOS] Add core-dump info on default signal dispositions This commit adds default signal dispositions (as per Linux) to all 32 standard signals. It also adds WCOREDUMP bit to correctly inform wait4() status word. This commit updates graphene-tests submodules to enable new killXX LTP regression tests, as well as fix the waitpid05 LTP test. It is important to update this submodule reference in this commit because otherwise waitpid05 tests will fail Graphene's CI. --- LibOS/shim/src/bookkeep/shim_signal.c | 40 ++++++++++++++++++--------- LibOS/shim/src/sys/shim_exit.c | 1 + LibOS/shim/test/apps | 2 +- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/LibOS/shim/src/bookkeep/shim_signal.c b/LibOS/shim/src/bookkeep/shim_signal.c index d1bc3fd6..61feab9a 100644 --- a/LibOS/shim/src/bookkeep/shim_signal.c +++ b/LibOS/shim/src/bookkeep/shim_signal.c @@ -747,16 +747,20 @@ void append_signal (struct shim_thread * thread, int sig, siginfo_t * info, } } +#define __WCOREDUMP_BIT 0x80 + static void sighandler_kill (int sig, siginfo_t * info, void * ucontext) { + int sig_without_coredump_bit = sig & ~(__WCOREDUMP_BIT); + __UNUSED(ucontext); - debug("killed by %s\n", signal_name(sig)); + debug("killed by %s\n", signal_name(sig_without_coredump_bit)); if (!info->si_pid) switch(sig) { case SIGTERM: case SIGINT: - shim_do_kill(-1, sig); + shim_do_kill(-1, sig_without_coredump_bit); break; } @@ -764,10 +768,11 @@ static void sighandler_kill (int sig, siginfo_t * info, void * ucontext) DkThreadExit(); } -/* We don't currently implement core dumps, but put a wrapper - * in case we do in the future */ static void sighandler_core (int sig, siginfo_t * info, void * ucontext) { + /* NOTE: This implementation only indicates the core dump for wait4() + * and friends. No actual core-dump file is created. */ + sig = __WCOREDUMP_BIT | sig; sighandler_kill(sig, info, ucontext); } @@ -775,24 +780,33 @@ static void (*default_sighandler[NUM_SIGS]) (int, siginfo_t *, void *) = { /* SIGHUP */ &sighandler_kill, /* SIGINT */ &sighandler_kill, - /* SIGQUIT */ &sighandler_kill, - /* SIGILL */ &sighandler_kill, + /* SIGQUIT */ &sighandler_core, + /* SIGILL */ &sighandler_core, /* SIGTRAP */ &sighandler_core, - /* SIGABRT */ &sighandler_kill, - /* SIGBUS */ &sighandler_kill, - /* SIGFPE */ &sighandler_kill, + /* SIGABRT */ &sighandler_core, + /* SIGBUS */ &sighandler_core, + /* SIGFPE */ &sighandler_core, /* SIGKILL */ &sighandler_kill, - /* SIGUSR1 */ NULL, - /* SIGSEGV */ &sighandler_kill, - /* SIGUSR2 */ NULL, + /* SIGUSR1 */ &sighandler_kill, + /* SIGSEGV */ &sighandler_core, + /* SIGUSR2 */ &sighandler_kill, /* SIGPIPE */ &sighandler_kill, /* SIGALRM */ &sighandler_kill, /* SIGTERM */ &sighandler_kill, - /* SIGSTKFLT */ NULL, + /* SIGSTKFLT */ &sighandler_kill, /* SIGCHLD */ NULL, /* SIGCONT */ NULL, /* SIGSTOP */ NULL, /* SIGTSTP */ NULL, /* SIGTTIN */ NULL, /* SIGTTOU */ NULL, + /* SIGURG */ NULL, + /* SIGXCPU */ &sighandler_core, + /* SIGXFSZ */ &sighandler_core, + /* SIGVTALRM */ &sighandler_kill, + /* SIGPROF */ &sighandler_kill, + /* SIGWINCH */ NULL, + /* SIGIO */ &sighandler_kill, + /* SIGPWR */ &sighandler_kill, + /* SIGSYS */ &sighandler_core }; diff --git a/LibOS/shim/src/sys/shim_exit.c b/LibOS/shim/src/sys/shim_exit.c index 6ae43464..af5d1cb1 100644 --- a/LibOS/shim/src/sys/shim_exit.c +++ b/LibOS/shim/src/sys/shim_exit.c @@ -129,6 +129,7 @@ int thread_exit(struct shim_thread * self, bool send_ipc) return 0; } +/* note that term_signal argument may contain WCOREDUMP bit (0x80) */ int try_process_exit (int error_code, int term_signal) { struct shim_thread * cur_thread = get_cur_thread(); diff --git a/LibOS/shim/test/apps b/LibOS/shim/test/apps index 827ef34a..ee85191b 160000 --- a/LibOS/shim/test/apps +++ b/LibOS/shim/test/apps @@ -1 +1 @@ -Subproject commit 827ef34af137483d1052597172b344df2b849c5c +Subproject commit ee85191b33eae777d7b65c118d84a609e511e953