Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit d862334

Browse files
committed
[Sanitizers] Export aligned new/delete from runtimes.
Summary: Export aligned new/delete to make dynamic runtimes work again. Remove all valid new/delete cases from ASan test, there's a test in common for that. Reviewers: eugenis Subscribers: srhines, kubamracek, #sanitizers, llvm-commits Differential Revision: https://reviews.llvm.org/D41548 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321394 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 4d53d6d commit d862334

File tree

3 files changed

+26
-34
lines changed

3 files changed

+26
-34
lines changed

lib/sanitizer_common/scripts/gen_dynamic_list.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,32 @@
2626
'_Znwm', '_ZnwmRKSt9nothrow_t', # operator new(unsigned long)
2727
'_Znaj', '_ZnajRKSt9nothrow_t', # operator new[](unsigned int)
2828
'_Znwj', '_ZnwjRKSt9nothrow_t', # operator new(unsigned int)
29+
# operator new(unsigned long, std::align_val_t)
30+
'_ZnwmSt11align_val_t', '_ZnwmSt11align_val_tRKSt9nothrow_t',
31+
# operator new(unsigned int, std::align_val_t)
32+
'_ZnwjSt11align_val_t', '_ZnwjSt11align_val_tRKSt9nothrow_t',
33+
# operator new[](unsigned long, std::align_val_t)
34+
'_ZnamSt11align_val_t', '_ZnamSt11align_val_tRKSt9nothrow_t',
35+
# operator new[](unsigned int, std::align_val_t)
36+
'_ZnajSt11align_val_t', '_ZnajSt11align_val_tRKSt9nothrow_t',
2937
'_ZdaPv', '_ZdaPvRKSt9nothrow_t', # operator delete[](void *)
3038
'_ZdlPv', '_ZdlPvRKSt9nothrow_t', # operator delete(void *)
3139
'_ZdaPvm', # operator delete[](void*, unsigned long)
3240
'_ZdlPvm', # operator delete(void*, unsigned long)
3341
'_ZdaPvj', # operator delete[](void*, unsigned int)
3442
'_ZdlPvj', # operator delete(void*, unsigned int)
43+
# operator delete(void*, std::align_val_t)
44+
'_ZdlPvSt11align_val_t', '_ZdlPvSt11align_val_tRKSt9nothrow_t',
45+
# operator delete[](void*, std::align_val_t)
46+
'_ZdaPvSt11align_val_t', '_ZdaPvSt11align_val_tRKSt9nothrow_t',
47+
# operator delete(void*, unsigned long, std::align_val_t)
48+
'_ZdlPvmSt11align_val_t',
49+
# operator delete[](void*, unsigned long, std::align_val_t)
50+
'_ZdaPvmSt11align_val_t',
51+
# operator delete(void*, unsigned int, std::align_val_t)
52+
'_ZdlPvjSt11align_val_t',
53+
# operator delete[](void*, unsigned int, std::align_val_t)
54+
'_ZdaPvjSt11align_val_t',
3555
])
3656

3757
versioned_functions = set(['memcpy', 'pthread_attr_getaffinity_np',

test/asan/TestCases/Linux/aligned_delete_test.cc

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
// RUN: %env_asan_opts=new_delete_type_mismatch=1:halt_on_error=false:detect_leaks=false %run %t 2>&1 | FileCheck %s
77
// RUN: %env_asan_opts=new_delete_type_mismatch=0 %run %t
88

9-
// REQUIRES: asan-static-runtime
10-
119
#include <stdio.h>
1210

1311
// Define all new/delete to do not depend on the version provided by the
14-
// plaform. The implementation is provided by ASan anyway.
12+
// platform. The implementation is provided by ASan anyway.
1513

1614
namespace std {
1715
struct nothrow_t {};
@@ -57,34 +55,8 @@ struct alignas(1024) S1024_1024 { char a[1024]; };
5755

5856

5957
int main(int argc, char **argv) {
60-
fprintf(stderr, "Testing valid cases\n");
61-
62-
delete break_optimization(new S12);
63-
operator delete(break_optimization(new S12), std::nothrow);
64-
delete [] break_optimization(new S12[100]);
65-
operator delete[](break_optimization(new S12[100]), std::nothrow);
66-
67-
delete break_optimization(new S12_128);
68-
operator delete(break_optimization(new S12_128),
69-
std::align_val_t(alignof(S12_128)));
70-
operator delete(break_optimization(new S12_128),
71-
std::align_val_t(alignof(S12_128)), std::nothrow);
72-
operator delete(break_optimization(new S12_128), sizeof(S12_128),
73-
std::align_val_t(alignof(S12_128)));
74-
75-
delete [] break_optimization(new S12_128[100]);
76-
operator delete[](break_optimization(new S12_128[100]),
77-
std::align_val_t(alignof(S12_128)));
78-
operator delete[](break_optimization(new S12_128[100]),
79-
std::align_val_t(alignof(S12_128)), std::nothrow);
80-
operator delete[](break_optimization(new S12_128[100]), sizeof(S12_128[100]),
81-
std::align_val_t(alignof(S12_128)));
82-
83-
fprintf(stderr, "Done\n");
84-
// CHECK: Testing valid cases
85-
// CHECK-NEXT: Done
86-
87-
// Explicit mismatched calls.
58+
// Check the mismatched calls only, all the valid cases are verified in
59+
// test/sanitizer_common/TestCases/Linux/new_delete_test.cc.
8860

8961
operator delete(break_optimization(new S12_128), std::nothrow);
9062
// CHECK: AddressSanitizer: new-delete-type-mismatch

test/sanitizer_common/TestCases/Linux/new_delete_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// RUN: %clangxx -std=c++1z -faligned-allocation -O0 %s -o %t && %run %t
22
// RUN: %clangxx -std=c++1z -faligned-allocation -fsized-deallocation -O0 %s -o %t && %run %t
33

4-
// ubsan does not intercept new/delete, adnroid is to be fixed.
5-
// UNSUPPORTED: ubsan,android
4+
// ubsan does not intercept new/delete.
5+
// UNSUPPORTED: ubsan
66

77
// Check that all new/delete variants are defined and work with supported
88
// sanitizers. Sanitizer-specific failure modes tests are supposed to go to
@@ -11,7 +11,7 @@
1111
#include <cstddef>
1212

1313
// Define all new/delete to do not depend on the version provided by the
14-
// plaform. The implementation is provided by the sanitizer anyway.
14+
// platform. The implementation is provided by the sanitizer anyway.
1515

1616
namespace std {
1717
struct nothrow_t {};

0 commit comments

Comments
 (0)