From 23c0cdd2ad8b15defab56eca89a42c67cadd9a34 Mon Sep 17 00:00:00 2001 From: antirez Date: Tue, 27 Mar 2012 15:24:33 +0200 Subject: [PATCH] Produce the watchlog warning log in a way that is safer from a signal handler. Fix a memory leak in the backtrace generation function. --- src/debug.c | 41 +++++++++++++++++++++++++++++++---------- src/zmalloc.c | 4 ++++ src/zmalloc.h | 1 + 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/debug.c b/src/debug.c index 30fb0091..49c76824 100644 --- a/src/debug.c +++ b/src/debug.c @@ -559,10 +559,11 @@ void logRegisters(ucontext_t *uc) { } /* Logs the stack trace using the backtrace() call. */ -void logStackTrace(ucontext_t *uc) { +sds getStackTrace(ucontext_t *uc) { void *trace[100]; int i, trace_size = 0; char **messages = NULL; + sds st = sdsempty(); /* Generate the stack trace */ trace_size = backtrace(trace, 100); @@ -572,9 +573,12 @@ void logStackTrace(ucontext_t *uc) { trace[1] = getMcontextEip(uc); } messages = backtrace_symbols(trace, trace_size); - redisLog(REDIS_WARNING, "--- STACK TRACE"); - for (i=1; i