From 4a3c59a53e94f930a2e37061ce448f852b3ce7e5 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 9 Jan 2017 21:53:31 -0600 Subject: [PATCH] global/signal_handler: dump backtrace even from within logging code We can dump the backtrace regardless of where we hit the assertion. Signed-off-by: Sage Weil --- src/global/signal_handler.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/global/signal_handler.cc b/src/global/signal_handler.cc index e8f21c1610a..66db79d2b20 100644 --- a/src/global/signal_handler.cc +++ b/src/global/signal_handler.cc @@ -111,19 +111,19 @@ static void handle_fatal_signal(int signum) dout_emergency(buf); pidfile_remove(); + // TODO: don't use an ostringstream here. It could call malloc(), which we + // don't want inside a signal handler. + // Also fix the backtrace code not to allocate memory. + BackTrace bt(0); + ostringstream oss; + bt.print(oss); + dout_emergency(oss.str()); + // avoid recursion back into logging code if that is where // we got the SEGV. if (g_ceph_context && g_ceph_context->_log && !g_ceph_context->_log->is_inside_log_lock()) { - // TODO: don't use an ostringstream here. It could call malloc(), which we - // don't want inside a signal handler. - // Also fix the backtrace code not to allocate memory. - BackTrace bt(0); - ostringstream oss; - bt.print(oss); - dout_emergency(oss.str()); - // dump to log. this uses the heap extensively, but we're better // off trying than not. derr << buf << std::endl; -- 2.47.3