Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prov/shm: Fix signal handling bug #5613

Merged
merged 1 commit into from
Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions prov/shm/src/smr_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
#include "smr.h"
#include "smr_signal.h"

extern struct sigaction *old_action;

struct smr_env smr_env = {
.disable_cma = 0,
};
Expand Down Expand Up @@ -153,6 +155,7 @@ static int smr_getinfo(uint32_t version, const char *node, const char *service,
static void smr_fini(void)
{
smr_cleanup();
free(old_action);
}

struct fi_provider smr_prov = {
Expand All @@ -177,7 +180,12 @@ SHM_INI
copying data directly between processes (default: no)");
smr_init_env();

old_action = calloc(SIGRTMIN, sizeof(*old_action));
if (!old_action)
return NULL;
/* Signal handlers to cleanup tmpfs files on an unclean shutdown */
assert(SIGBUS < SIGRTMIN && SIGSEGV < SIGRTMIN
&& SIGTERM < SIGRTMIN && SIGINT < SIGRTMIN);
smr_reg_sig_hander(SIGBUS);
smr_reg_sig_hander(SIGSEGV);
smr_reg_sig_hander(SIGTERM);
Expand Down
6 changes: 3 additions & 3 deletions prov/shm/src/smr_signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#include <signal.h>
#include <ofi_shm.h>

struct sigaction old_action;
struct sigaction *old_action;

static void smr_handle_signal(int signum, siginfo_t *info, void *ucontext)
{
Expand All @@ -49,7 +49,7 @@ static void smr_handle_signal(int signum, siginfo_t *info, void *ucontext)
}

/* Register the original signum handler, SIG_DFL or otherwise */
ret = sigaction(signum, &old_action, NULL);
ret = sigaction(signum, &old_action[signum], NULL);
shefty marked this conversation as resolved.
Show resolved Hide resolved
if (ret)
return;

Expand All @@ -66,7 +66,7 @@ static void smr_reg_sig_hander(int signum)
action.sa_sigaction = smr_handle_signal;
action.sa_flags |= SA_SIGINFO;

ret = sigaction(signum, &action, &old_action);
ret = sigaction(signum, &action, &old_action[signum]);
shefty marked this conversation as resolved.
Show resolved Hide resolved
if (ret)
FI_WARN(&smr_prov, FI_LOG_FABRIC,
"Unable to register handler for sig %d\n", signum);
Expand Down