[compiler-rt] r276332 - [asan] Fix Win64 test portability issues

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 14:04:35 PDT 2016


Author: rnk
Date: Thu Jul 21 16:04:34 2016
New Revision: 276332

URL: http://llvm.org/viewvc/llvm-project?rev=276332&view=rev
Log:
[asan] Fix Win64 test portability issues

The OOM test should really only run on 32-bits, since it's hard to OOM
on x64.

The operator_array_new_with_dtor_left_oob tests need to account for the
larger array cookie on x64 (8 bytes instead of 4).

Use -std=c++14 in use-after-scope-capture.cc to avoid errors in the MSVC
2015 STL on Windows. The default there is C++14 anyway.

Modified:
    compiler-rt/trunk/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cc
    compiler-rt/trunk/test/asan/TestCases/Windows/oom.cc
    compiler-rt/trunk/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cc
    compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cc?rev=276332&r1=276331&r2=276332&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/dll_operator_array_new_with_dtor_left_oob.cc Thu Jul 21 16:04:34 2016
@@ -10,7 +10,7 @@ struct C {
 extern "C" __declspec(dllexport)
 int test_function() {
   C *buffer = new C[42];
-  buffer[-2].x = 42;
+  buffer[-(1 + sizeof(void*) / 4)].x = 42;
 // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
 // CHECK: WRITE of size 4 at [[ADDR]] thread T0
 // CHECK-NEXT: test_function {{.*}}dll_operator_array_new_with_dtor_left_oob.cc:[[@LINE-3]]
@@ -19,7 +19,7 @@ int test_function() {
 // FIXME: Currently it says "4 bytes ... left of 172-byte region",
 //        should be "8 bytes ... left of 168-byte region", see
 //        https://code.google.com/p/address-sanitizer/issues/detail?id=314
-// CHECK: [[ADDR]] is located {{.*}} bytes to the left of 172-byte region
+// CHECK: [[ADDR]] is located {{.*}} bytes to the left of {{(172|176)}}-byte region
 // FIXME: Should get rid of the malloc/free frames called from the inside of
 // operator new/delete in DLLs when using -MT CRT.
 // FIXME: The operator new frame should have [].

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/oom.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/oom.cc?rev=276332&r1=276331&r2=276332&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/oom.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/oom.cc Thu Jul 21 16:04:34 2016
@@ -1,5 +1,6 @@
 // RUN: %clang_cl_asan -O0 %s -Fe%t
 // RUN: not %run %t 2>&1 | FileCheck %s
+// REQUIRES: asan-32-bits
 
 #include <malloc.h>
 

Modified: compiler-rt/trunk/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cc?rev=276332&r1=276331&r2=276332&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/Windows/operator_array_new_with_dtor_left_oob.cc Thu Jul 21 16:04:34 2016
@@ -8,7 +8,7 @@ struct C {
 
 int main() {
   C *buffer = new C[42];
-  buffer[-2].x = 42;
+  buffer[-(1 + sizeof(void*) / 4)].x = 42;
 // CHECK: AddressSanitizer: heap-buffer-overflow on address [[ADDR:0x[0-9a-f]+]]
 // CHECK: WRITE of size 4 at [[ADDR]] thread T0
 // CHECK-NEXT: {{#0 .* main .*operator_array_new_with_dtor_left_oob.cc}}:[[@LINE-3]]
@@ -16,7 +16,7 @@ int main() {
 // FIXME: Currently it says "4 bytes ... left of 172-byte region",
 //        should be "8 bytes ... left of 168-byte region", see
 //        https://code.google.com/p/address-sanitizer/issues/detail?id=314
-// CHECK: [[ADDR]] is located {{.*}} bytes to the left of 172-byte region
+// CHECK: [[ADDR]] is located {{.*}} bytes to the left of {{(172|176)}}-byte region
 // CHECK-LABEL: allocated by thread T0 here:
 // FIXME: The 'operator new' frame should have [].
 // CHECK-NEXT: {{#0 .* operator new}}

Modified: compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc?rev=276332&r1=276331&r2=276332&view=diff
==============================================================================
--- compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc (original)
+++ compiler-rt/trunk/test/asan/TestCases/use-after-scope-capture.cc Thu Jul 21 16:04:34 2016
@@ -1,4 +1,4 @@
-// RUN: %clangxx_asan -std=c++11 -O1 -fsanitize-address-use-after-scope %s -o %t && \
+// RUN: %clangxx_asan -std=c++14 -O1 -fsanitize-address-use-after-scope %s -o %t && \
 // RUN:     not %run %t 2>&1 | FileCheck %s
 
 #include <functional>




More information about the llvm-commits mailing list