From a829ca9104ea7e784b634b303ddc0073dfeb76ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Wed, 29 Apr 2020 20:02:44 +0200 Subject: [PATCH] Generate a detailed backtrace on crash --- lib/ProxySQL_GloVars.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/ProxySQL_GloVars.cpp b/lib/ProxySQL_GloVars.cpp index ea7a02948..84fbe2a15 100644 --- a/lib/ProxySQL_GloVars.cpp +++ b/lib/ProxySQL_GloVars.cpp @@ -4,6 +4,7 @@ #include #include #include "SpookyV2.h" +#include static void term_handler(int sig) { proxy_warning("Received TERM signal: shutdown in progress...\n"); @@ -17,6 +18,8 @@ void crash_handler(int sig) { // malloc_stats_print(NULL, NULL, ""); #endif #ifdef __GLIBC__ +#define DEBUG_MSG_MAXSIZE 1024 + char debugbuff[DEBUG_MSG_MAXSIZE]; void *arr[20]; size_t s; @@ -24,6 +27,26 @@ void crash_handler(int sig) { fprintf(stderr, "Error: signal %d:\n", sig); backtrace_symbols_fd(arr, s, STDERR_FILENO); + + char **strings; + strings=backtrace_symbols(arr,s); + if (strings == NULL) { + perror("backtrace_symbols failed!"); + } else { + for (unsigned int i=0; i