Merge pull request #2713 from sysown/v2.1.0-backtrace

V2.1.0 backtrace
pull/2676/head^2
René Cannaò 6 years ago committed by GitHub
commit b367eadf75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@
#include <string>
#include <sys/utsname.h>
#include "SpookyV2.h"
#include <cxxabi.h>
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<s; i++) {
debugbuff[0]=0;
sscanf(strings[i], "%*[^(](%100[^+]", debugbuff);
int status;
char *realname=NULL;
realname=abi::__cxa_demangle(debugbuff, 0, 0, &status);
if (realname) {
fprintf(stderr," ---- %s : %s\n", strings[i], realname);
}
}
//free(strings); // we don't free, we are crashing anyway
}
#endif /* __GLIBC__ */
// try to generate a core dump signaling again the thread
signal(sig, SIG_DFL);

@ -1754,6 +1754,7 @@ gotofork:
} else {
GloAdmin->flush_error_log();
GloVars.install_signal_handler();
}
__start_label:

Loading…
Cancel
Save