diff options
author | Petr Hosek <phosek@chromium.org> | 2017-09-06 02:43:54 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2017-09-06 02:43:54 +0000 |
commit | 53335d6d86d5a3790d8fd6bcfa8860a577ccabfd (patch) | |
tree | dda34af080e9217d68b48e8302258cbbfd3c604a /libcxxabi/src | |
parent | 0aa4b7d4c5e97b5157a784848d977fc142918ef2 (diff) | |
download | bcm5719-llvm-53335d6d86d5a3790d8fd6bcfa8860a577ccabfd.tar.gz bcm5719-llvm-53335d6d86d5a3790d8fd6bcfa8860a577ccabfd.zip |
[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_return
The ASan runtime on many systems intercepts cxa_throw just so it
can call asan_handle_no_return first. Some newer systems such as
Fuchsia don't use interceptors on standard library functions at all,
but instead use sanitizer-instrumented versions of the standard
libraries. When libc++abi is built with ASan, cxa_throw can just
call asan_handle_no_return itself so no interceptor is required.
This is a re-land of r311045, which has become safe after r311869
changed compiler-rt to declare __asan_handle_no_return.
Patch by Roland McGrath
Differential Revision: https://reviews.llvm.org/D37229
llvm-svn: 312606
Diffstat (limited to 'libcxxabi/src')
-rw-r--r-- | libcxxabi/src/cxa_exception.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libcxxabi/src/cxa_exception.cpp b/libcxxabi/src/cxa_exception.cpp index 0794444bcc5..204ea2ded00 100644 --- a/libcxxabi/src/cxa_exception.cpp +++ b/libcxxabi/src/cxa_exception.cpp @@ -19,6 +19,10 @@ #include "cxa_handlers.hpp" #include "fallback_malloc.h" +#if __has_feature(address_sanitizer) +#include <sanitizer/asan_interface.h> +#endif + // +---------------------------+-----------------------------+---------------+ // | __cxa_exception | _Unwind_Exception CLNGC++\0 | thrown object | // +---------------------------+-----------------------------+---------------+ @@ -217,6 +221,12 @@ __cxa_throw(void *thrown_object, std::type_info *tinfo, void (*dest)(void *)) { globals->uncaughtExceptions += 1; // Not atomically, since globals are thread-local exception_header->unwindHeader.exception_cleanup = exception_cleanup_func; + +#if __has_feature(address_sanitizer) + // Inform the ASan runtime that now might be a good time to clean stuff up. + __asan_handle_no_return(); +#endif + #ifdef __USING_SJLJ_EXCEPTIONS__ _Unwind_SjLj_RaiseException(&exception_header->unwindHeader); #else |