diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-15 20:55:28 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-15 20:55:28 -0400 |
commit | 125c8e54680c936b9e532597372c62ac47af4fa9 (patch) | |
tree | 63fb1b62472d16eb220cf4e4313d6ac902210212 /src/common/backtrace.c | |
parent | 03e0c7e36608ba3830c3e6948529a3aca2edcfc1 (diff) | |
parent | bd83d0ed186c0bb2c8e3892e55ac2f55770d3ee7 (diff) | |
download | tor-125c8e54680c936b9e532597372c62ac47af4fa9.tar.gz tor-125c8e54680c936b9e532597372c62ac47af4fa9.zip |
Merge remote-tracking branch 'public/bug11465'
Diffstat (limited to 'src/common/backtrace.c')
-rw-r--r-- | src/common/backtrace.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/common/backtrace.c b/src/common/backtrace.c index 239c65782b..3a073a8ff5 100644 --- a/src/common/backtrace.c +++ b/src/common/backtrace.c @@ -5,7 +5,6 @@ #define _GNU_SOURCE 1 #include "orconfig.h" -#include "backtrace.h" #include "compat.h" #include "util.h" #include "torlog.h" @@ -31,6 +30,9 @@ #include <ucontext.h> #endif +#define EXPOSE_CLEAN_BACKTRACE +#include "backtrace.h" + #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE) && \ defined(HAVE_BACKTRACE_SYMBOLS_FD) && defined(HAVE_SIGACTION) #define USE_BACKTRACE @@ -59,7 +61,7 @@ static tor_mutex_t cb_buf_mutex; * onto the stack. Fortunately, we usually have the program counter in the * ucontext_t structure. */ -static void +void clean_backtrace(void **stack, int depth, const ucontext_t *ctx) { #ifdef PC_FROM_UCONTEXT @@ -165,6 +167,18 @@ install_bt_handler(void) rv = -1; } } + + { + /* Now, generate (but do not log) a backtrace. This ensures that + * libc has pre-loaded the symbols we need to dump things, so that later + * reads won't be denied by the sandbox code */ + char **symbols; + int depth = backtrace(cb_buf, MAX_DEPTH); + symbols = backtrace_symbols(cb_buf, depth); + if (symbols) + free(symbols); + } + return rv; } |