aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-08-30 21:17:07 +1000
committerteor <teor@torproject.org>2019-08-30 21:51:07 +1000
commit65a1d86491d56c77048d01e0b4fc6b933a13795c (patch)
tree1f810ae50081db7e6bbf0aeffeb84a8c6e837714
parent743bc0028be46e92a46b3b5e38f1e50ee69ff284 (diff)
downloadtor-65a1d86491d56c77048d01e0b4fc6b933a13795c.tar.gz
tor-65a1d86491d56c77048d01e0b4fc6b933a13795c.zip
torerr: Log the Tor backtrace version when a raw assertion fails
Part of 31571.
-rw-r--r--src/lib/err/backtrace.c8
-rw-r--r--src/lib/err/backtrace.h1
-rw-r--r--src/lib/err/torerr.c3
3 files changed, 11 insertions, 1 deletions
diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c
index c34eb6dfa6..a4d8269c6a 100644
--- a/src/lib/err/backtrace.c
+++ b/src/lib/err/backtrace.c
@@ -261,6 +261,14 @@ dump_stack_symbols_to_error_fds(void)
}
#endif /* defined(NO_BACKTRACE_IMPL) */
+/** Return the tor version used for error messages on crashes.
+ * Signal-safe: returns a pointer to a static array. */
+const char *
+get_tor_backtrace_version(void)
+{
+ return bt_version;
+}
+
/** Set up code to handle generating error messages on crashes. */
int
configure_backtrace_handler(const char *tor_version)
diff --git a/src/lib/err/backtrace.h b/src/lib/err/backtrace.h
index 9b313261e6..48b41fca02 100644
--- a/src/lib/err/backtrace.h
+++ b/src/lib/err/backtrace.h
@@ -21,6 +21,7 @@ void log_backtrace_impl(int severity, int domain, const char *msg,
int configure_backtrace_handler(const char *tor_version);
void clean_up_backtrace_handler(void);
void dump_stack_symbols_to_error_fds(void);
+const char *get_tor_backtrace_version(void);
#define log_backtrace(sev, dom, msg) \
log_backtrace_impl((sev), (dom), (msg), tor_log)
diff --git a/src/lib/err/torerr.c b/src/lib/err/torerr.c
index 54acf722aa..88b19b7327 100644
--- a/src/lib/err/torerr.c
+++ b/src/lib/err/torerr.c
@@ -144,7 +144,8 @@ tor_raw_assertion_failed_msg_(const char *file, int line, const char *expr,
{
char linebuf[16];
format_dec_number_sigsafe(line, linebuf, sizeof(linebuf));
- tor_log_err_sigsafe("INTERNAL ERROR: Raw assertion failed at ",
+ tor_log_err_sigsafe("INTERNAL ERROR: Raw assertion failed in ",
+ get_tor_backtrace_version(), " at ",
file, ":", linebuf, ": ", expr, NULL);
if (msg) {
tor_log_err_sigsafe_write(msg);