[compiler-rt] r328646 - [HWASan] Make use-after-free c, not c++ test.

Alex Shlyapnikov via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 27 10:45:53 PDT 2018


Author: alekseyshl
Date: Tue Mar 27 10:45:53 2018
New Revision: 328646

URL: http://llvm.org/viewvc/llvm-project?rev=328646&view=rev
Log:
[HWASan] Make use-after-free c, not c++ test.

To minimize testing surface (remove libstdc++ from the picture, for
one), make use-after-free c, not c++ test.

Differential Revision: https://reviews.llvm.org/D44705

Added:
    compiler-rt/trunk/test/hwasan/TestCases/use-after-free.c
Removed:
    compiler-rt/trunk/test/hwasan/TestCases/use-after-free.cc

Added: compiler-rt/trunk/test/hwasan/TestCases/use-after-free.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/hwasan/TestCases/use-after-free.c?rev=328646&view=auto
==============================================================================
--- compiler-rt/trunk/test/hwasan/TestCases/use-after-free.c (added)
+++ compiler-rt/trunk/test/hwasan/TestCases/use-after-free.c Tue Mar 27 10:45:53 2018
@@ -0,0 +1,39 @@
+// RUN: %clang_hwasan -O0 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
+// RUN: %clang_hwasan -O1 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
+// RUN: %clang_hwasan -O2 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
+// RUN: %clang_hwasan -O3 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
+
+// RUN: %clang_hwasan -O0 -DSTORE %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,STORE
+
+// REQUIRES: stable-runtime
+
+#include <stdlib.h>
+#include <sanitizer/hwasan_interface.h>
+
+int main() {
+  __hwasan_enable_allocator_tagging();
+  char * volatile x = (char*)malloc(10);
+  free(x);
+  __hwasan_disable_allocator_tagging();
+#ifdef STORE
+  x[5] = 42;
+#endif
+#ifdef LOAD
+  return x[5];
+#endif
+  // LOAD: READ of size 1 at
+  // LOAD: #0 {{.*}} in main {{.*}}use-after-free.c:22
+
+  // STORE: WRITE of size 1 at
+  // STORE: #0 {{.*}} in main {{.*}}use-after-free.c:19
+
+  // CHECK: freed here:
+  // CHECK: #0 {{.*}} in {{.*}}free{{.*}} {{.*}}hwasan_interceptors.cc
+  // CHECK: #1 {{.*}} in main {{.*}}use-after-free.c:16
+
+  // CHECK: previously allocated here:
+  // CHECK: #0 {{.*}} in {{.*}}malloc{{.*}} {{.*}}hwasan_interceptors.cc
+  // CHECK: #1 {{.*}} in main {{.*}}use-after-free.c:15
+
+  // CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main
+}

Removed: compiler-rt/trunk/test/hwasan/TestCases/use-after-free.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/hwasan/TestCases/use-after-free.cc?rev=328645&view=auto
==============================================================================
--- compiler-rt/trunk/test/hwasan/TestCases/use-after-free.cc (original)
+++ compiler-rt/trunk/test/hwasan/TestCases/use-after-free.cc (removed)
@@ -1,39 +0,0 @@
-// RUN: %clangxx_hwasan -O0 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
-// RUN: %clangxx_hwasan -O1 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
-// RUN: %clangxx_hwasan -O2 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
-// RUN: %clangxx_hwasan -O3 -DLOAD %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,LOAD
-
-// RUN: %clangxx_hwasan -O0 -DSTORE %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK,STORE
-
-// REQUIRES: stable-runtime
-
-#include <stdlib.h>
-#include <sanitizer/hwasan_interface.h>
-
-int main() {
-  __hwasan_enable_allocator_tagging();
-  char * volatile x = (char*)malloc(10);
-  free(x);
-  __hwasan_disable_allocator_tagging();
-#ifdef STORE
-  x[5] = 42;
-#endif
-#ifdef LOAD
-  return x[5];
-#endif
-  // LOAD: READ of size 1 at
-  // LOAD: #0 {{.*}} in main {{.*}}use-after-free.cc:22
-
-  // STORE: WRITE of size 1 at
-  // STORE: #0 {{.*}} in main {{.*}}use-after-free.cc:19
-
-  // CHECK: freed here:
-  // CHECK: #0 {{.*}} in {{.*}}free{{.*}} {{.*}}hwasan_interceptors.cc
-  // CHECK: #1 {{.*}} in main {{.*}}use-after-free.cc:16
-
-  // CHECK: previously allocated here:
-  // CHECK: #0 {{.*}} in {{.*}}malloc{{.*}} {{.*}}hwasan_interceptors.cc
-  // CHECK: #1 {{.*}} in main {{.*}}use-after-free.cc:15
-
-  // CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main
-}




More information about the llvm-commits mailing list