Don't use an alternative stack for SIGSEGV & co.

This commit reverts most of c575766202, in
order to use back main stack for signal handling.

The main reason is that otherwise it is completely pointless that we do
a lot of efforts to print the stack trace on crash, and the content of
the stack and registers as well. Using an alternate stack broken this
feature completely.
This commit is contained in:
antirez 2012-04-26 16:21:19 +02:00
parent 28ccb53008
commit 3ada43e732

View File

@ -62,9 +62,6 @@ double R_Zero, R_PosInf, R_NegInf, R_Nan;
/*================================= Globals ================================= */ /*================================= Globals ================================= */
/* Alternate stack for SIGSEGV/etc handlers */
char altstack[SIGSTKSZ];
/* Global vars */ /* Global vars */
struct redisServer server; /* server global state */ struct redisServer server; /* server global state */
struct redisCommand *commandTable; struct redisCommand *commandTable;
@ -2351,13 +2348,6 @@ static void sigtermHandler(int sig) {
void setupSignalHandlers(void) { void setupSignalHandlers(void) {
struct sigaction act; struct sigaction act;
stack_t stack;
stack.ss_sp = altstack;
stack.ss_flags = 0;
stack.ss_size = SIGSTKSZ;
sigaltstack(&stack, NULL);
/* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction is used. /* When the SA_SIGINFO flag is set in sa_flags then sa_sigaction is used.
* Otherwise, sa_handler is used. */ * Otherwise, sa_handler is used. */
@ -2367,10 +2357,8 @@ void setupSignalHandlers(void) {
sigaction(SIGTERM, &act, NULL); sigaction(SIGTERM, &act, NULL);
#ifdef HAVE_BACKTRACE #ifdef HAVE_BACKTRACE
/* Use alternate stack so we don't clobber stack in case of segv, or when we run out of stack ..
* also resethand & nodefer so we can get interrupted (and killed) if we cause SEGV during SEGV handler */
sigemptyset(&act.sa_mask); sigemptyset(&act.sa_mask);
act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND | SA_SIGINFO; act.sa_flags = SA_NODEFER | SA_RESETHAND | SA_SIGINFO;
act.sa_sigaction = sigsegvHandler; act.sa_sigaction = sigsegvHandler;
sigaction(SIGSEGV, &act, NULL); sigaction(SIGSEGV, &act, NULL);
sigaction(SIGBUS, &act, NULL); sigaction(SIGBUS, &act, NULL);