696d846a56
libsanitizer/ 2015-10-20 Maxim Ostapenko <m.ostapenko@partner.samsung.com> * All source files: Merge from upstream r250806. * configure.ac (link_sanitizer_common): Add -lrt flag. * configure.tgt: Enable TSAN and LSAN for aarch64-linux targets. Set CXX_ABI_NEEDED=true for darwin. * asan/Makefile.am (asan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0 and remove unused and legacy DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0. * asan/Makefile.in: Regenerate. * ubsan/Makefile.am (ubsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=1. (libubsan_la_LIBADD): Add -lc++abi if CXX_ABI_NEEDED is true. * ubsan/Makefile.in: Regenerate. * tsan/Makefile.am (tsan_files): Add new files. (DEFS): Add DCAN_SANITIZE_UB=0. * tsan/Makefile.in: Regenerate. * sanitizer_common/Makefile.am (sanitizer_common_files): Add new files. * sanitizer_common/Makefile.in: Regenerate. * asan/libtool-version: Bump the libasan SONAME. From-SVN: r229111
87 lines
2.5 KiB
C++
87 lines
2.5 KiB
C++
//===-- tsan_new_delete.cc ----------------------------------------------===//
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file is a part of ThreadSanitizer (TSan), a race detector.
|
|
//
|
|
// Interceptors for operators new and delete.
|
|
//===----------------------------------------------------------------------===//
|
|
#include "sanitizer_common/sanitizer_internal_defs.h"
|
|
#include "tsan_interceptors.h"
|
|
|
|
using namespace __tsan; // NOLINT
|
|
|
|
namespace std {
|
|
struct nothrow_t {};
|
|
} // namespace std
|
|
|
|
#define OPERATOR_NEW_BODY(mangled_name) \
|
|
if (cur_thread()->in_symbolizer) \
|
|
return __libc_malloc(size); \
|
|
void *p = 0; \
|
|
{ \
|
|
SCOPED_INTERCEPTOR_RAW(mangled_name, size); \
|
|
p = user_alloc(thr, pc, size); \
|
|
} \
|
|
invoke_malloc_hook(p, size); \
|
|
return p;
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void *operator new(__sanitizer::uptr size);
|
|
void *operator new(__sanitizer::uptr size) {
|
|
OPERATOR_NEW_BODY(_Znwm);
|
|
}
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void *operator new[](__sanitizer::uptr size);
|
|
void *operator new[](__sanitizer::uptr size) {
|
|
OPERATOR_NEW_BODY(_Znam);
|
|
}
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void *operator new(__sanitizer::uptr size, std::nothrow_t const&);
|
|
void *operator new(__sanitizer::uptr size, std::nothrow_t const&) {
|
|
OPERATOR_NEW_BODY(_ZnwmRKSt9nothrow_t);
|
|
}
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void *operator new[](__sanitizer::uptr size, std::nothrow_t const&);
|
|
void *operator new[](__sanitizer::uptr size, std::nothrow_t const&) {
|
|
OPERATOR_NEW_BODY(_ZnamRKSt9nothrow_t);
|
|
}
|
|
|
|
#define OPERATOR_DELETE_BODY(mangled_name) \
|
|
if (ptr == 0) return; \
|
|
if (cur_thread()->in_symbolizer) \
|
|
return __libc_free(ptr); \
|
|
invoke_free_hook(ptr); \
|
|
SCOPED_INTERCEPTOR_RAW(mangled_name, ptr); \
|
|
user_free(thr, pc, ptr);
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void operator delete(void *ptr) NOEXCEPT;
|
|
void operator delete(void *ptr) NOEXCEPT {
|
|
OPERATOR_DELETE_BODY(_ZdlPv);
|
|
}
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void operator delete[](void *ptr) NOEXCEPT;
|
|
void operator delete[](void *ptr) NOEXCEPT {
|
|
OPERATOR_DELETE_BODY(_ZdaPv);
|
|
}
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void operator delete(void *ptr, std::nothrow_t const&);
|
|
void operator delete(void *ptr, std::nothrow_t const&) {
|
|
OPERATOR_DELETE_BODY(_ZdlPvRKSt9nothrow_t);
|
|
}
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
void operator delete[](void *ptr, std::nothrow_t const&);
|
|
void operator delete[](void *ptr, std::nothrow_t const&) {
|
|
OPERATOR_DELETE_BODY(_ZdaPvRKSt9nothrow_t);
|
|
}
|