Created
March 1, 2010 02:53
-
-
Save noahd1/318038 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void segvHandler(int sig, siginfo_t *info, void *secret) { | |
void *trace[100]; | |
char **messages = NULL; | |
int i, trace_size = 0; | |
unsigned long offset=0; | |
ucontext_t *uc = (ucontext_t*) secret; | |
sds infostring; | |
REDIS_NOTUSED(info); | |
redisLog(REDIS_WARNING, | |
"======= Ooops! Redis %s got signal: -%d- =======", REDIS_VERSION, sig); | |
infostring = genRedisInfoString(); | |
redisLog(REDIS_WARNING, "%s",infostring); | |
/* It's not safe to sdsfree() the returned string under memory | |
* corruption conditions. Let it leak as we are going to abort */ | |
trace_size = backtrace(trace, 100); | |
/* overwrite sigaction with caller's address */ | |
if (getMcontextEip(uc) != NULL) { | |
trace[1] = getMcontextEip(uc); | |
} | |
messages = backtrace_symbols(trace, trace_size); | |
for (i=1; i<trace_size; ++i) { | |
char *fn = findFuncName(trace[i], &offset), *p; | |
p = strchr(messages[i],'+'); | |
if (!fn || (p && ((unsigned long)strtol(p+1,NULL,10)) < offset)) { | |
redisLog(REDIS_WARNING,"%s", messages[i]); | |
} else { | |
redisLog(REDIS_WARNING,"%d redis-server %p %s + %d", i, trace[i], fn, (unsigned int)offset); | |
} | |
} | |
/* free(messages); Don't call free() with possibly corrupted memory. */ | |
_exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment