[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Remove abort handler from the backtrace generator



commit 04f21f03221a3888bde376ee1c2daa1effccbb4e
Author: cypherpunks <cypherpunks@xxxxxxxxxxxxxx>
Date:   Sun Dec 18 15:55:37 2016 +0000

    Remove abort handler from the backtrace generator
    
    The abort handler masks the exit status of the backtrace generator by
    capturing the abort signal from the backtrace handler and exiting with
    zero. Because the output of the backtrace generator is meant to be piped
    to `bt_test.py`, its exit status is unimportant and is currently
    ignored.
    
    The abort handler calls `exit(3)` which is not asynchronous-signal-safe
    and calling it in this context is undefined behavior [0].
    
    Closes ticket 21026.
    
    [0] https://www.securecoding.cert.org/confluence/x/34At
---
 changes/ticket21026   |  3 +++
 src/test/test_bt_cl.c | 11 -----------
 2 files changed, 3 insertions(+), 11 deletions(-)

diff --git a/changes/ticket21026 b/changes/ticket21026
new file mode 100644
index 0000000..530a52c
--- /dev/null
+++ b/changes/ticket21026
@@ -0,0 +1,3 @@
+  o Minor bugfixes (testing):
+    - Remove undefined behavior from the backtrace generator by removing
+      its signal handler. Fixes bug 21026; bugfix on 0.2.5.2-alpha.
diff --git a/src/test/test_bt_cl.c b/src/test/test_bt_cl.c
index 95b4f48..709d599 100644
--- a/src/test/test_bt_cl.c
+++ b/src/test/test_bt_cl.c
@@ -19,14 +19,12 @@ static int crashtype = 0;
 
 #ifdef __GNUC__
 #define NOINLINE __attribute__((noinline))
-#define NORETURN __attribute__((noreturn))
 #endif
 
 int crash(int x) NOINLINE;
 int oh_what(int x) NOINLINE;
 int a_tangled_web(int x) NOINLINE;
 int we_weave(int x) NOINLINE;
-static void abort_handler(int s) NORETURN;
 
 #ifdef HAVE_CFLAG_WNULL_DEREFERENCE
 DISABLE_GCC_WARNING(null-dereference)
@@ -76,13 +74,6 @@ we_weave(int x)
   return a_tangled_web(x) + a_tangled_web(x+1);
 }
 
-static void
-abort_handler(int s)
-{
-  (void)s;
-  exit(0);
-}
-
 int
 main(int argc, char **argv)
 {
@@ -120,8 +111,6 @@ main(int argc, char **argv)
 
   configure_backtrace_handler(NULL);
 
-  signal(SIGABRT, abort_handler);
-
   printf("%d\n", we_weave(2));
 
   clean_up_backtrace_handler();

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits