]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
torerr: Try harder to flush raw assert messages before process termination
authorteor <teor@torproject.org>
Fri, 30 Aug 2019 11:17:56 +0000 (21:17 +1000)
committerteor <teor@torproject.org>
Fri, 30 Aug 2019 11:51:11 +0000 (21:51 +1000)
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.

Fixes bug 31571; bugfix on 0.3.5.1-alpha.

changes/bug31571 [new file with mode: 0644]
src/lib/err/torerr.c

diff --git a/changes/bug31571 b/changes/bug31571
new file mode 100644 (file)
index 0000000..86de353
--- /dev/null
@@ -0,0 +1,7 @@
+  o Minor bugfixes (error handling):
+    - Report the tor version whenever an assertion fails. Previously, we only
+      reported the Tor version on some crashes, and some non-fatal assertions.
+      Fixes bug 31571; bugfix on 0.3.5.1-alpha.
+    - On abort, try harder to flush the output buffers of log messages. On
+      some platforms (macOS), log messages can be discarded when the process
+      terminates. Fixes bug 31571; bugfix on 0.3.5.1-alpha.
index 88b19b7327683f6d968cc58757d8f5f747fc031e..6b5224273a507002e4999dc141c78ca4b56a7c52 100644 (file)
@@ -146,13 +146,19 @@ tor_raw_assertion_failed_msg_(const char *file, int line, const char *expr,
   format_dec_number_sigsafe(line, linebuf, sizeof(linebuf));
   tor_log_err_sigsafe("INTERNAL ERROR: Raw assertion failed in ",
                       get_tor_backtrace_version(), " at ",
-                      file, ":", linebuf, ": ", expr, NULL);
+                      file, ":", linebuf, ": ", expr, "\n", NULL);
   if (msg) {
     tor_log_err_sigsafe_write(msg);
     tor_log_err_sigsafe_write("\n");
   }
 
   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");
 }
 
 /* As format_{hex,dex}_number_sigsafe, but takes a <b>radix</b> argument