[tor-commits] [tor/release-0.4.0] backtrace: Always set a backtrace Tor version
teor at torproject.org
teor at torproject.org
Thu Dec 5 00:16:40 UTC 2019
commit e2a7d08aa7c51fa903d5294628612a13b4c0d6e0
Author: teor <teor at torproject.org>
Date: Fri Aug 30 21:12:52 2019 +1000
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.
---
src/lib/err/backtrace.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c
index 1d1b3bcfa..8cca3c37e 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
More information about the tor-commits
mailing list