aboutsummaryrefslogtreecommitdiff
path: root/src/lib/err
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2019-09-04 14:50:09 +1000
committerteor <teor@torproject.org>2019-09-24 13:35:48 +1000
commit6b97a5a843341b5ea2a9039bdd5290d524a44cd4 (patch)
treebb277692d219d8fa88a6d216ea72a33df55cbaa1 /src/lib/err
parent02840169d860384257042bdf6d7601c2bf48b47b (diff)
downloadtor-6b97a5a843341b5ea2a9039bdd5290d524a44cd4.tar.gz
tor-6b97a5a843341b5ea2a9039bdd5290d524a44cd4.zip
backtrace: Disable signal handlers in remove_bt_handler()
Fixes bug 31614; bugfix on 0.2.5.2-alpha.
Diffstat (limited to 'src/lib/err')
-rw-r--r--src/lib/err/backtrace.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/lib/err/backtrace.c b/src/lib/err/backtrace.c
index 1d1b3bcfa3..77dc6b8cbf 100644
--- a/src/lib/err/backtrace.c
+++ b/src/lib/err/backtrace.c
@@ -190,13 +190,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(const char *software)
{
- int trap_signals[] = { SIGSEGV, SIGILL, SIGFPE, SIGBUS, SIGSYS,
- SIGIO, -1 };
int i, rv=0;
strncpy(bt_version, software, sizeof(bt_version) - 1);
@@ -235,6 +237,19 @@ install_bt_handler(const char *software)
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);
+ }
}
#endif /* defined(USE_BACKTRACE) */