1 // RUN: %clangxx_hwasan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=COMMON
2 // RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=1 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
3 // RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
5 // RUN: %clangxx_hwasan -O0 %s -o %t -fsanitize-recover=hwaddress && not %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
6 // RUN: %clangxx_hwasan -O0 %s -o %t -fsanitize-recover=hwaddress && not %env_hwasan_opts=halt_on_error=1 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
7 // RUN: %clangxx_hwasan -O0 %s -o %t -fsanitize-recover=hwaddress && not %env_hwasan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s --check-prefixes=COMMON,RECOVER
9 // RUN: %clangxx_hwasan -mllvm -hwasan-instrument-with-calls=1 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
10 // RUN: %clangxx_hwasan -mllvm -hwasan-instrument-with-calls=1 -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=1 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
11 // RUN: %clangxx_hwasan -mllvm -hwasan-instrument-with-calls=1 -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
13 // RUN: %clangxx_hwasan -mllvm -hwasan-instrument-with-calls=1 -O0 %s -o %t -fsanitize-recover=hwaddress && not %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
14 // RUN: %clangxx_hwasan -mllvm -hwasan-instrument-with-calls=1 -O0 %s -o %t -fsanitize-recover=hwaddress && not %env_hwasan_opts=halt_on_error=1 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON
15 // RUN: %clangxx_hwasan -mllvm -hwasan-instrument-with-calls=1 -O0 %s -o %t -fsanitize-recover=hwaddress && not %env_hwasan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s --check-prefixes=COMMON,RECOVER
17 // REQUIRES: stable-runtime
20 #include <sanitizer/hwasan_interface.h>
23 __hwasan_enable_allocator_tagging();
24 int* volatile x
= (int*)malloc(16);
26 __hwasan_disable_allocator_tagging();
27 return x
[2] + ((char *)x
)[6] + ((char *)x
)[9];
28 // COMMON: READ of size 4 at
29 // When instrumenting with callbacks, main is actually #1, and #0 is __hwasan_load4.
30 // COMMON: #{{.*}} in main {{.*}}halt-on-error.cpp:27
31 // COMMON: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in
33 // RECOVER: READ of size 1 at
34 // RECOVER: #{{.*}} in main {{.*}}halt-on-error.cpp:27
35 // RECOVER: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in
37 // RECOVER: READ of size 1 at
38 // RECOVER: #{{.*}} in main {{.*}}halt-on-error.cpp:27
39 // RECOVER: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in
41 // COMMON-NOT: tag-mismatch