summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/asan_new_delete.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler-rt/lib/asan/asan_new_delete.cc')
-rw-r--r--compiler-rt/lib/asan/asan_new_delete.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/asan_new_delete.cc b/compiler-rt/lib/asan/asan_new_delete.cc
index 0c8c9e97776..30efd61a968 100644
--- a/compiler-rt/lib/asan/asan_new_delete.cc
+++ b/compiler-rt/lib/asan/asan_new_delete.cc
@@ -14,6 +14,7 @@
#include "asan_allocator.h"
#include "asan_internal.h"
+#include "asan_malloc_local.h"
#include "asan_report.h"
#include "asan_stack.h"
@@ -69,12 +70,24 @@ enum class align_val_t: size_t {};
} // namespace std
// TODO(alekseyshl): throw std::bad_alloc instead of dying on OOM.
+// For local pool allocation, align to SHADOW_GRANULARITY to match asan
+// allocator behavior.
#define OPERATOR_NEW_BODY(type, nothrow) \
+ if (ALLOCATE_FROM_LOCAL_POOL) {\
+ void *res = MemalignFromLocalPool(SHADOW_GRANULARITY, size);\
+ if (!nothrow) CHECK(res);\
+ return res;\
+ }\
GET_STACK_TRACE_MALLOC;\
void *res = asan_memalign(0, size, &stack, type);\
if (!nothrow && UNLIKELY(!res)) ReportOutOfMemory(size, &stack);\
return res;
#define OPERATOR_NEW_BODY_ALIGN(type, nothrow) \
+ if (ALLOCATE_FROM_LOCAL_POOL) {\
+ void *res = MemalignFromLocalPool((uptr)align, size);\
+ if (!nothrow) CHECK(res);\
+ return res;\
+ }\
GET_STACK_TRACE_MALLOC;\
void *res = asan_memalign((uptr)align, size, &stack, type);\
if (!nothrow && UNLIKELY(!res)) ReportOutOfMemory(size, &stack);\
@@ -129,18 +142,22 @@ INTERCEPTOR(void *, _ZnamRKSt9nothrow_t, size_t size, std::nothrow_t const&) {
#endif // !SANITIZER_MAC
#define OPERATOR_DELETE_BODY(type) \
+ if (IS_FROM_LOCAL_POOL(ptr)) return;\
GET_STACK_TRACE_FREE;\
asan_delete(ptr, 0, 0, &stack, type);
#define OPERATOR_DELETE_BODY_SIZE(type) \
+ if (IS_FROM_LOCAL_POOL(ptr)) return;\
GET_STACK_TRACE_FREE;\
asan_delete(ptr, size, 0, &stack, type);
#define OPERATOR_DELETE_BODY_ALIGN(type) \
+ if (IS_FROM_LOCAL_POOL(ptr)) return;\
GET_STACK_TRACE_FREE;\
asan_delete(ptr, 0, static_cast<uptr>(align), &stack, type);
#define OPERATOR_DELETE_BODY_SIZE_ALIGN(type) \
+ if (IS_FROM_LOCAL_POOL(ptr)) return;\
GET_STACK_TRACE_FREE;\
asan_delete(ptr, size, static_cast<uptr>(align), &stack, type);
OpenPOWER on IntegriCloud