Skip to content

Commit

Permalink
[libcxxabi] When built with ASan, __cxa_throw calls __asan_handle_no_…
Browse files Browse the repository at this point in the history
…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.

Patch by Roland McGrath

Differential Revision: https://reviews.llvm.org/D36599

llvm-svn: 311045
  • Loading branch information
petrhosek committed Aug 16, 2017
1 parent 882f296 commit 0013556
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions libcxxabi/src/cxa_exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
// +---------------------------+-----------------------------+---------------+
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0013556

Please sign in to comment.