diff options
author | teor <teor@torproject.org> | 2019-08-30 21:12:52 +1000 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-08-30 21:50:57 +1000 |
commit | e2a7d08aa7c51fa903d5294628612a13b4c0d6e0 (patch) | |
tree | 2b3e50bbc0a636016577d4b22a5ed64632b057e7 /src/lib/err | |
parent | 190386f1c44462fbef568ca9e3c1c997dbebcf12 (diff) | |
download | tor-e2a7d08aa7c51fa903d5294628612a13b4c0d6e0.tar.gz tor-e2a7d08aa7c51fa903d5294628612a13b4c0d6e0.zip |
backtrace: Always set a backtrace Tor version
We want to report the tor version, even on platforms that don't have
backtrace support (like Android).
This commit stores the backtrace Tor version, regardless of USE_BACKTRACE.
Preparation for 31571.
Diffstat (limited to 'src/lib/err')
-rw-r--r-- | src/lib/err/backtrace.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c index 1d1b3bcfa3..8cca3c37e7 100644 --- a/src/lib/err/backtrace.c +++ b/src/lib/err/backtrace.c @@ -68,10 +68,10 @@ // Redundant with util.h, but doing it here so we can avoid that dependency. #define raw_free free -#ifdef USE_BACKTRACE /** Version of Tor to report in backtrace messages. */ static char bt_version[128] = ""; +#ifdef USE_BACKTRACE /** Largest stack depth to try to dump. */ #define MAX_DEPTH 256 /** Static allocation of stack to dump. This is static so we avoid stack @@ -193,15 +193,12 @@ dump_stack_symbols_to_error_fds(void) /** Install signal handlers as needed so that when we crash, we produce a * useful stack trace. Return 0 on success, -errno on failure. */ static int -install_bt_handler(const char *software) +install_bt_handler(void) { int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, -1 }; int i, rv=0; - strncpy(bt_version, software, sizeof(bt_version) - 1); - bt_version[sizeof(bt_version) - 1] = 0; - struct sigaction sa; memset(&sa, 0, sizeof(sa)); @@ -247,9 +244,8 @@ log_backtrace_impl(int severity, int domain, const char *msg, } static int -install_bt_handler(const char *software) +install_bt_handler(void) { - (void) software; return 0; } @@ -274,7 +270,10 @@ configure_backtrace_handler(const char *tor_version) snprintf(version, sizeof(version), "Tor %s", tor_version); } - return install_bt_handler(version); + strncpy(bt_version, version, sizeof(bt_version) - 1); + bt_version[sizeof(bt_version) - 1] = 0; + + return install_bt_handler(); } /** Perform end-of-process cleanup for code that generates error messages on |