[compiler-rt] r321394 - [Sanitizers] Export aligned new/delete from runtimes.

Alex Shlyapnikov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 22 16:30:52 PST 2017


Author: alekseyshl
Date: Fri Dec 22 16:30:51 2017
New Revision: 321394

URL: http://llvm.org/viewvc/llvm-project?rev=321394&view=rev
Log:
[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

Modified:
    compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py
    compiler-rt/trunk/test/asan/TestCases/Linux/aligned_delete_test.cc
    compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/new_delete_test.cc

Modified: compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py?rev=321394&r1=321393&r2=321394&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py (original)
+++ compiler-rt/trunk/lib/sanitizer_common/scripts/gen_dynamic_list.py Fri Dec 22 16:30:51 2017
@@ -26,12 +26,32 @@ new_delete = set([
                   '_Znwm', '_ZnwmRKSt9nothrow_t',    # operator new(unsigned long)
                   '_Znaj', '_ZnajRKSt9nothrow_t',    # operator new[](unsigned int)
                   '_Znwj', '_ZnwjRKSt9nothrow_t',    # operator new(unsigned int)
+                  # operator new(unsigned long, std::align_val_t)
+                  '_ZnwmSt11align_val_t', '_ZnwmSt11align_val_tRKSt9nothrow_t',
+                  # operator new(unsigned int, std::align_val_t)
+                  '_ZnwjSt11align_val_t', '_ZnwjSt11align_val_tRKSt9nothrow_t',
+                  # operator new[](unsigned long, std::align_val_t)
+                  '_ZnamSt11align_val_t', '_ZnamSt11align_val_tRKSt9nothrow_t',
+                  # operator new[](unsigned int, std::align_val_t)
+                  '_ZnajSt11align_val_t', '_ZnajSt11align_val_tRKSt9nothrow_t',
                   '_ZdaPv', '_ZdaPvRKSt9nothrow_t',  # operator delete[](void *)
                   '_ZdlPv', '_ZdlPvRKSt9nothrow_t',  # operator delete(void *)
                   '_ZdaPvm',                         # operator delete[](void*, unsigned long)
                   '_ZdlPvm',                         # operator delete(void*, unsigned long)
                   '_ZdaPvj',                         # operator delete[](void*, unsigned int)
                   '_ZdlPvj',                         # operator delete(void*, unsigned int)
+                  # operator delete(void*, std::align_val_t)
+                  '_ZdlPvSt11align_val_t', '_ZdlPvSt11align_val_tRKSt9nothrow_t',
+                  # operator delete[](void*, std::align_val_t)
+                  '_ZdaPvSt11align_val_t', '_ZdaPvSt11align_val_tRKSt9nothrow_t',
+                  # operator delete(void*, unsigned long,  std::align_val_t)
+                  '_ZdlPvmSt11align_val_t',
+                  # operator delete[](void*, unsigned long, std::align_val_t)
+                  '_ZdaPvmSt11align_val_t',
+                  # operator delete(void*, unsigned int,  std::align_val_t)
+                  '_ZdlPvjSt11align_val_t',
+                  # operator delete[](void*, unsigned int, std::align_val_t)
+                  '_ZdaPvjSt11align_val_t',
                   ])
 
 versioned_functions = set(['memcpy', 'pthread_attr_getaffinity_np',

Modified: compiler-rt/trunk/test/asan/TestCases/Linux/aligned_delete_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Linux/aligned_delete_test.cc?rev=321394&r1=321393&r2=321394&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/aligned_delete_test.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Linux/aligned_delete_test.cc Fri Dec 22 16:30:51 2017
@@ -6,12 +6,10 @@
 // RUN: %env_asan_opts=new_delete_type_mismatch=1:halt_on_error=false:detect_leaks=false %run %t 2>&1 | FileCheck %s
 // RUN: %env_asan_opts=new_delete_type_mismatch=0                                        %run %t
 
-// REQUIRES: asan-static-runtime
-
 #include <stdio.h>
 
 // Define all new/delete to do not depend on the version provided by the
-// plaform. The implementation is provided by ASan anyway.
+// platform. The implementation is provided by ASan anyway.
 
 namespace std {
 struct nothrow_t {};
@@ -57,34 +55,8 @@ struct alignas(1024) S1024_1024 { char a
 
 
 int main(int argc, char **argv) {
-  fprintf(stderr, "Testing valid cases\n");
-
-  delete break_optimization(new S12);
-  operator delete(break_optimization(new S12), std::nothrow);
-  delete [] break_optimization(new S12[100]);
-  operator delete[](break_optimization(new S12[100]), std::nothrow);
-
-  delete break_optimization(new S12_128);
-  operator delete(break_optimization(new S12_128),
-                  std::align_val_t(alignof(S12_128)));
-  operator delete(break_optimization(new S12_128),
-                  std::align_val_t(alignof(S12_128)), std::nothrow);
-  operator delete(break_optimization(new S12_128), sizeof(S12_128),
-                  std::align_val_t(alignof(S12_128)));
-
-  delete [] break_optimization(new S12_128[100]);
-  operator delete[](break_optimization(new S12_128[100]),
-                    std::align_val_t(alignof(S12_128)));
-  operator delete[](break_optimization(new S12_128[100]),
-                    std::align_val_t(alignof(S12_128)), std::nothrow);
-  operator delete[](break_optimization(new S12_128[100]), sizeof(S12_128[100]),
-                    std::align_val_t(alignof(S12_128)));
-
-  fprintf(stderr, "Done\n");
-  // CHECK: Testing valid cases
-  // CHECK-NEXT: Done
-
-  // Explicit mismatched calls.
+  // Check the mismatched calls only, all the valid cases are verified in
+  // test/sanitizer_common/TestCases/Linux/new_delete_test.cc.
 
   operator delete(break_optimization(new S12_128), std::nothrow);
   // CHECK: AddressSanitizer: new-delete-type-mismatch

Modified: compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/new_delete_test.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/new_delete_test.cc?rev=321394&r1=321393&r2=321394&view=diff
==============================================================================
--- compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/new_delete_test.cc (original)
+++ compiler-rt/trunk/test/sanitizer_common/TestCases/Linux/new_delete_test.cc Fri Dec 22 16:30:51 2017
@@ -1,8 +1,8 @@
 // RUN: %clangxx -std=c++1z -faligned-allocation -O0 %s -o %t && %run %t
 // RUN: %clangxx -std=c++1z -faligned-allocation -fsized-deallocation -O0 %s -o %t && %run %t
 
-// ubsan does not intercept new/delete, adnroid is to be fixed.
-// UNSUPPORTED: ubsan,android
+// ubsan does not intercept new/delete.
+// UNSUPPORTED: ubsan
 
 // Check that all new/delete variants are defined and work with supported
 // sanitizers. Sanitizer-specific failure modes tests are supposed to go to
@@ -11,7 +11,7 @@
 #include <cstddef>
 
 // Define all new/delete to do not depend on the version provided by the
-// plaform. The implementation is provided by the sanitizer anyway.
+// platform. The implementation is provided by the sanitizer anyway.
 
 namespace std {
 struct nothrow_t {};




More information about the llvm-commits mailing list