brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · b27ee34 Raw
41 lines · cpp
1// RUN: %clangxx_hwasan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefixes=COMMON2// RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=1 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON3// RUN: %clangxx_hwasan -O0 %s -o %t && not %env_hwasan_opts=halt_on_error=0 %run %t 2>&1 | FileCheck %s --check-prefix=COMMON4 5// RUN: %clangxx_hwasan -O0 %s -o %t -fsanitize-recover=hwaddress && not %run %t 2>&1 | FileCheck %s --check-prefix=COMMON6// 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=COMMON7// 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,RECOVER8 9// RUN: %clangxx_hwasan -mllvm -hwasan-instrument-with-calls=1 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=COMMON10// 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=COMMON11// 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=COMMON12 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=COMMON14// 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=COMMON15// 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,RECOVER16 17#include <stdlib.h>18#include <sanitizer/hwasan_interface.h>19 20int main() {21  __hwasan_enable_allocator_tagging();22  int* volatile x = (int*)malloc(16);23  free(x);24  __hwasan_disable_allocator_tagging();25  return x[2] + ((char *)x)[6] + ((char *)x)[9];26  // COMMON: READ of size 4 at27  // When instrumenting with callbacks, main is actually #1, and #0 is __hwasan_load4.28  // COMMON: #{{.*}} in main {{.*}}halt-on-error.cpp:[[@LINE-3]]29  // COMMON: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main30 31  // RECOVER: READ of size 1 at32  // RECOVER: #{{.*}} in main {{.*}}halt-on-error.cpp:[[@LINE-7]]33  // RECOVER: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main34 35  // RECOVER: READ of size 1 at36  // RECOVER: #{{.*}} in main {{.*}}halt-on-error.cpp:[[@LINE-11]]37  // RECOVER: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main38 39  // COMMON-NOT: tag-mismatch40}41