diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2017-12-19 22:57:02 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2017-12-19 22:57:02 +0000 |
commit | 0e12fa83247fdb0adc10da354797c7bf47ab2e88 (patch) | |
tree | d64d4d0e8fcda5931d5bd09a0ffcb0af935692c8 /test/hwasan/TestCases | |
parent | ebd3997dd6d9781b04908f5201afaedc93f709ca (diff) |
[hwasan] Fix handling of store errors.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@321121 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/hwasan/TestCases')
-rw-r--r-- | test/hwasan/TestCases/use-after-free.cc | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/test/hwasan/TestCases/use-after-free.cc b/test/hwasan/TestCases/use-after-free.cc index a4433b8de..37637898d 100644 --- a/test/hwasan/TestCases/use-after-free.cc +++ b/test/hwasan/TestCases/use-after-free.cc @@ -1,7 +1,10 @@ -// RUN: %clangxx_hwasan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK -// RUN: %clangxx_hwasan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK -// RUN: %clangxx_hwasan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK -// RUN: %clangxx_hwasan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK +// 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> @@ -9,20 +12,28 @@ int main() { __hwasan_enable_allocator_tagging(); - char *x = (char*)malloc(10); + char * volatile x = (char*)malloc(10); free(x); __hwasan_disable_allocator_tagging(); +#ifdef STORE + x[5] = 42; +#endif +#ifdef LOAD return x[5]; - // CHECK: READ of size 1 at - // CHECK: #0 {{.*}} in main {{.*}}use-after-free.cc:15 +#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:13 + // CHECK: #1 {{.*}} in main {{.*}}use-after-free.cc:16 // CHECK: previously allocated here: // CHECK: #0 {{.*}} in __interceptor_malloc {{.*}}hwasan_interceptors.cc - // CHECK: #1 {{.*}} in main {{.*}}use-after-free.cc:12 + // CHECK: #1 {{.*}} in main {{.*}}use-after-free.cc:15 // CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main } |