torerr: Log the Tor backtrace version when a raw assertion fails

Part of 31571.
This commit is contained in:
teor 2019-08-30 21:17:07 +10:00
parent 743bc0028b
commit 65a1d86491
No known key found for this signature in database
GPG Key ID: 10FEAA0E7075672A
3 changed files with 11 additions and 1 deletions

View File

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

View File

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

View File

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