[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.4.0] torerr: Log the Tor backtrace version when a raw assertion fails



commit 65a1d86491d56c77048d01e0b4fc6b933a13795c
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Fri Aug 30 21:17:07 2019 +1000

    torerr: Log the Tor backtrace version when a raw assertion fails
    
    Part of 31571.
---
 src/lib/err/backtrace.c | 8 ++++++++
 src/lib/err/backtrace.h | 1 +
 src/lib/err/torerr.c    | 3 ++-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c
index c34eb6dfa..a4d8269c6 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 9b313261e..48b41fca0 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 54acf722a..88b19b732 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);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits