[tor-commits] [tor/release-0.4.2] Merge branch 'maint-0.4.0' into maint-0.4.1
teor at torproject.org
teor at torproject.org
Thu Dec 5 00:16:40 UTC 2019
commit cfa9cc34aa36c0f300724a01998633efbe8439ea
Merge: 14089a29b 92fb09906
Author: teor <teor at torproject.org>
Date: Thu Dec 5 10:14:01 2019 +1000
Merge branch 'maint-0.4.0' into maint-0.4.1
changes/bug31571 | 7 +++++++
changes/bug31810 | 4 ++++
src/lib/err/backtrace.c | 42 ++++++++++++++++++++++++++++++-----------
src/lib/err/backtrace.h | 1 +
src/lib/err/torerr.c | 11 +++++++++--
src/lib/process/process_unix.c | 9 +--------
src/lib/process/process_win32.c | 18 ++++++++++++++++++
src/test/test_process_slow.c | 30 +++++++++++++++++++++++++++++
8 files changed, 101 insertions(+), 21 deletions(-)
diff --cc src/lib/err/backtrace.c
index 2408a6851,8606f4217..8bc7e6965
--- a/src/lib/err/backtrace.c
+++ b/src/lib/err/backtrace.c
@@@ -198,13 -193,12 +198,10 @@@ static int trap_signals[] = { SIGSEGV,
/** 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));
@@@ -260,10 -237,11 +257,11 @@@ remove_bt_handler(void
#ifdef NO_BACKTRACE_IMPL
void
-log_backtrace_impl(int severity, int domain, const char *msg,
+log_backtrace_impl(int severity, log_domain_mask_t domain, const char *msg,
tor_log_fn logger)
{
- logger(severity, domain, "%s. (Stack trace not available)", msg);
+ logger(severity, domain, "%s: %s. (Stack trace not available)",
+ bt_version, msg);
}
static int
diff --cc src/lib/err/torerr.c
index 21b28a5f6,1a246e995..b7e32a3e2
--- a/src/lib/err/torerr.c
+++ b/src/lib/err/torerr.c
@@@ -206,20 -163,14 +207,26 @@@ tor_raw_assertion_failed_msg_(const cha
}
dump_stack_symbols_to_error_fds();
+
+ /* Some platforms (macOS, maybe others?) can swallow the last write before an
+ * abort. This issue is probably caused by a race condition between write
+ * buffer cache flushing, and process termination. So we write an extra
+ * newline, to make sure that the message always gets through. */
+ tor_log_err_sigsafe_write("\n");
}
+/**
+ * Call the abort() function to kill the current process with a fatal
+ * error. But first, close the raw error file descriptors, so error messages
+ * are written before process termination.
+ **/
+void
+tor_raw_abort_(void)
+{
+ tor_log_close_sigsafe_err_fds();
+ abort();
+}
+
/* As format_{hex,dex}_number_sigsafe, but takes a <b>radix</b> argument
* in range 2..16 inclusive. */
static int
More information about the tor-commits
mailing list