diff options
author | George Kadianakis <desnacked@riseup.net> | 2019-04-25 15:43:47 +0300 |
---|---|---|
committer | George Kadianakis <desnacked@riseup.net> | 2019-04-25 15:43:47 +0300 |
commit | 811a93f80333d0f31ea9a46d9a1606c8e4ef11da (patch) | |
tree | 7115e31f92fcd023a06816a70639c0d6dc3a65aa /src | |
parent | 6320b2988c59afb69c80ee0855579960e40a77d8 (diff) | |
parent | 358df18064d0389219e610cf9aa5b08bbd6a0ec8 (diff) | |
download | tor-811a93f80333d0f31ea9a46d9a1606c8e4ef11da.tar.gz tor-811a93f80333d0f31ea9a46d9a1606c8e4ef11da.zip |
Merge branch 'tor-github/pr/953'
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/log/util_bug.c | 14 | ||||
-rw-r--r-- | src/lib/log/util_bug.h | 8 |
2 files changed, 19 insertions, 3 deletions
diff --git a/src/lib/log/util_bug.c b/src/lib/log/util_bug.c index 65ab7bc9c6..76b97c1a08 100644 --- a/src/lib/log/util_bug.c +++ b/src/lib/log/util_bug.c @@ -19,6 +19,7 @@ #include "lib/string/printf.h" #include <string.h> +#include <stdlib.h> #ifdef TOR_UNIT_TESTS static void (*failed_assertion_cb)(void) = NULL; @@ -159,6 +160,19 @@ tor_bug_occurred_(const char *fname, unsigned int line, #endif } +/** + * Call the abort() function to kill the current process with a fatal + * error. + * + * (This is a separate function so that we declare it in util_bug.h without + * including stdlib in all the users of util_bug.h) + **/ +void +tor_abort_(void) +{ + abort(); +} + #ifdef _WIN32 /** Take a filename and return a pointer to its final element. This * function is called on __FILE__ to fix a MSVC nit where __FILE__ diff --git a/src/lib/log/util_bug.h b/src/lib/log/util_bug.h index 63c5309c98..2e220b7286 100644 --- a/src/lib/log/util_bug.h +++ b/src/lib/log/util_bug.h @@ -106,7 +106,7 @@ } else { \ tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, #expr, \ fmt, ##__VA_ARGS__); \ - abort(); \ + tor_abort_(); \ } STMT_END #endif /* defined(TOR_UNIT_TESTS) && defined(DISABLE_ASSERTS_IN_UNIT_TESTS) */ @@ -114,7 +114,7 @@ STMT_BEGIN { \ tor_assertion_failed_(SHORT_FILE__, __LINE__, __func__, \ "line should be unreached", NULL); \ - abort(); \ + tor_abort_(); \ } STMT_END /* Non-fatal bug assertions. The "unreached" variants mean "this line should @@ -149,7 +149,7 @@ #define BUG(cond) \ (ASSERT_PREDICT_UNLIKELY_(cond) ? \ (tor_assertion_failed_(SHORT_FILE__,__LINE__,__func__,"!("#cond")"), \ - abort(), 1) \ + tor_abort_(), 1) \ : 0) #elif defined(TOR_UNIT_TESTS) && defined(DISABLE_ASSERTS_IN_UNIT_TESTS) #define tor_assert_nonfatal_unreached() STMT_NIL @@ -246,6 +246,8 @@ void tor_bug_occurred_(const char *fname, unsigned int line, const char *func, const char *expr, int once, const char *fmt, ...); +void tor_abort_(void) ATTR_NORETURN; + #ifdef _WIN32 #define SHORT_FILE__ (tor_fix_source_file(__FILE__)) const char *tor_fix_source_file(const char *fname); |