diff options
author | Alex Shlyapnikov <alekseys@google.com> | 2018-03-27 17:45:53 +0000 |
---|---|---|
committer | Alex Shlyapnikov <alekseys@google.com> | 2018-03-27 17:45:53 +0000 |
commit | 0c41e4c8cf77ed9fb28114cfaf430ac34e6c6e9c (patch) | |
tree | 87d9ce04795728824fb3cf1bd84bbd2e6be99870 /test | |
parent | 7741c0b35bb33e852c9e4bdfa1b71233a2e294eb (diff) |
[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
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@328646 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r-- | test/hwasan/TestCases/use-after-free.c | 39 | ||||
-rw-r--r-- | test/hwasan/TestCases/use-after-free.cc | 39 |
2 files changed, 39 insertions, 39 deletions
diff --git a/test/hwasan/TestCases/use-after-free.c b/test/hwasan/TestCases/use-after-free.c new file mode 100644 index 000000000..b9f606011 --- /dev/null +++ b/test/hwasan/TestCases/use-after-free.c @@ -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 +} diff --git a/test/hwasan/TestCases/use-after-free.cc b/test/hwasan/TestCases/use-after-free.cc deleted file mode 100644 index 6b9cf5a52..000000000 --- a/test/hwasan/TestCases/use-after-free.cc +++ /dev/null @@ -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 -} |