Loading changes/bug31614 0 → 100644 +9 −0 Original line number Diff line number Diff line o Minor bugfixes (logging): - Disable backtrace signal handlers when shutting down tor. Fixes bug 31614; bugfix on 0.2.5.2-alpha. - Add a missing check for HAVE_PTHREAD_H, because the backtrace code uses mutexes. Fixes bug 31614; bugfix on 0.2.5.2-alpha. o Documentation: - Explain why we can't destroy the backtrace buffer mutex. Explain why we don't need to destroy the log mutex. Closes ticket 31736. src/lib/err/backtrace.c +23 −3 Original line number Diff line number Diff line Loading @@ -57,7 +57,8 @@ #include "lib/err/torerr.h" #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) && \ defined(HAVE_PTHREAD_H) #define USE_BACKTRACE #endif Loading Loading @@ -190,13 +191,15 @@ dump_stack_symbols_to_error_fds(void) backtrace_symbols_fd(cb_buf, (int)depth, fds[i]); } /* The signals that we want our backtrace handler to trap */ static int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, -1 }; /** 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(void) { int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, -1 }; int i, rv=0; struct sigaction sa; Loading Loading @@ -232,6 +235,23 @@ install_bt_handler(void) static void remove_bt_handler(void) { int i; struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_DFL; sigfillset(&sa.sa_mask); for (i = 0; trap_signals[i] >= 0; ++i) { /* remove_bt_handler() is called on shutdown, from low-level code. * It's not a fatal error, so we just ignore it. */ (void)sigaction(trap_signals[i], &sa, NULL); } /* cb_buf_mutex is statically initialised, so we can not destroy it. * If we destroy it, and then re-initialise tor, all our backtraces will * fail. */ } #endif /* defined(USE_BACKTRACE) */ Loading src/lib/log/log.c +4 −1 Original line number Diff line number Diff line Loading @@ -832,7 +832,10 @@ logs_free_all(void) } /* We _could_ destroy the log mutex here, but that would screw up any logs * that happened between here and the end of execution. */ * that happened between here and the end of execution. * If tor is re-initialized, log_mutex_initialized will still be 1. So we * won't trigger any undefined behaviour by trying to re-initialize the * log mutex. */ } /** Close signal-safe log files. Loading src/lib/sandbox/sandbox.c +1 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,7 @@ sb_rt_sigaction(scmp_filter_ctx ctx, sandbox_cfg_t *filter) unsigned i; int rc; int param[] = { SIGINT, SIGTERM, SIGPIPE, SIGUSR1, SIGUSR2, SIGHUP, SIGCHLD, SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, #ifdef SIGXFSZ SIGXFSZ #endif Loading Loading
changes/bug31614 0 → 100644 +9 −0 Original line number Diff line number Diff line o Minor bugfixes (logging): - Disable backtrace signal handlers when shutting down tor. Fixes bug 31614; bugfix on 0.2.5.2-alpha. - Add a missing check for HAVE_PTHREAD_H, because the backtrace code uses mutexes. Fixes bug 31614; bugfix on 0.2.5.2-alpha. o Documentation: - Explain why we can't destroy the backtrace buffer mutex. Explain why we don't need to destroy the log mutex. Closes ticket 31736.
src/lib/err/backtrace.c +23 −3 Original line number Diff line number Diff line Loading @@ -57,7 +57,8 @@ #include "lib/err/torerr.h" #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) && \ defined(HAVE_PTHREAD_H) #define USE_BACKTRACE #endif Loading Loading @@ -190,13 +191,15 @@ dump_stack_symbols_to_error_fds(void) backtrace_symbols_fd(cb_buf, (int)depth, fds[i]); } /* The signals that we want our backtrace handler to trap */ static int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, -1 }; /** 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(void) { int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, -1 }; int i, rv=0; struct sigaction sa; Loading Loading @@ -232,6 +235,23 @@ install_bt_handler(void) static void remove_bt_handler(void) { int i; struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_DFL; sigfillset(&sa.sa_mask); for (i = 0; trap_signals[i] >= 0; ++i) { /* remove_bt_handler() is called on shutdown, from low-level code. * It's not a fatal error, so we just ignore it. */ (void)sigaction(trap_signals[i], &sa, NULL); } /* cb_buf_mutex is statically initialised, so we can not destroy it. * If we destroy it, and then re-initialise tor, all our backtraces will * fail. */ } #endif /* defined(USE_BACKTRACE) */ Loading
src/lib/log/log.c +4 −1 Original line number Diff line number Diff line Loading @@ -832,7 +832,10 @@ logs_free_all(void) } /* We _could_ destroy the log mutex here, but that would screw up any logs * that happened between here and the end of execution. */ * that happened between here and the end of execution. * If tor is re-initialized, log_mutex_initialized will still be 1. So we * won't trigger any undefined behaviour by trying to re-initialize the * log mutex. */ } /** Close signal-safe log files. Loading
src/lib/sandbox/sandbox.c +1 −0 Original line number Diff line number Diff line Loading @@ -294,6 +294,7 @@ sb_rt_sigaction(scmp_filter_ctx ctx, sandbox_cfg_t *filter) unsigned i; int rc; int param[] = { SIGINT, SIGTERM, SIGPIPE, SIGUSR1, SIGUSR2, SIGHUP, SIGCHLD, SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS, SIGIO, #ifdef SIGXFSZ SIGXFSZ #endif Loading