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.
This commit is contained in:
teor 2019-08-30 21:12:52 +10:00
parent 190386f1c4
commit e2a7d08aa7
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A

View File

@ -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