xref: /llvm-project/compiler-rt/test/hwasan/TestCases/wild-free-shadow.c (revision e772e25547b748812d61561a8a444e3c42a4cfc2)
1 // RUN: %clang_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
2 
3 #include <stdlib.h>
4 
5 extern void *__hwasan_shadow_memory_dynamic_address;
6 
main()7 int main() {
8   char *p = (char *)malloc(1);
9   free(__hwasan_shadow_memory_dynamic_address);
10   // CHECK: ERROR: HWAddressSanitizer: invalid-free on address {{[0x]+}}[[PTR:.*]] at pc {{[0x]+}}[[PC:.*]] on thread T{{[0-9]+}}
11   // CHECK: #0 {{[0x]+}}{{.*}}[[PC]] in {{.*}}free
12   // CHECK: #1 {{.*}} in main {{.*}}wild-free-shadow.c:[[@LINE-3]]
13   // CHECK: {{[0x]+}}{{.*}}[[PTR]] is HWAsan shadow memory.
14   // CHECK-NOT: Segmentation fault
15   // CHECK-NOT: SIGSEGV
16   return 0;
17 }
18