36 lines · c
1// RUN: %clang_hwasan_oldrt -DSIZE=2 -O0 %s -o %t && %run %t2// RUN: %clang_hwasan -DSIZE=2 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s3// RUN: %clang_hwasan_oldrt -DSIZE=15 -O0 %s -o %t && %run %t4// RUN: %clang_hwasan -DSIZE=15 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s5// RUN: %clang_hwasan_oldrt -DSIZE=16 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s6// RUN: %clang_hwasan -DSIZE=16 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s7// RUN: %clang_hwasan -DSIZE=64 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s8// RUN: %clang_hwasan -DSIZE=0x1000 -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s9 10// Stack short granules are currently not implemented on x86.11// RISC-V target doesn't support oldrt12// XFAIL: target={{(x86_64|riscv64).*}}13 14#include <stdlib.h>15#include <sanitizer/hwasan_interface.h>16 17__attribute__((noinline))18int f() {19 char z[SIZE];20 char *volatile p = z;21 return p[SIZE];22}23 24int main() {25 f();26 // CHECK: READ of size 1 at27 // CHECK: #0 {{.*}} in f{{.*}}stack-oob.c:[[@LINE-6]]28 29 // CHECK-NOT: Cause: global-overflow30 // CHECK: Cause: stack tag-mismatch31 // CHECK: is located in stack of threa32 // CHECK-NOT: Cause: global-overflow33 34 // CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in f35}36