From e21998feeeba8316714476ac4dddb70a41e6df5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Mon, 27 Apr 2020 19:44:23 +0200 Subject: [PATCH 1/2] Added signal handler installation when running in the foreground #2636 --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 6bc9c778a..fe951ac5a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1754,6 +1754,7 @@ gotofork: } else { GloAdmin->flush_error_log(); + GloVars.install_signal_handler(); } __start_label: 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 2/2] 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