[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / double-free.c
blob6d177fdef702909896f6904e3e9addd61da315f7
1 // RUN: %clang_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
3 // REQUIRES: stable-runtime
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <sanitizer/hwasan_interface.h>
9 int main() {
10 __hwasan_enable_allocator_tagging();
11 char * volatile x = (char*)malloc(40);
12 free(x);
13 free(x);
14 // CHECK: ERROR: HWAddressSanitizer: invalid-free on address {{.*}} at pc {{[0x]+}}[[PC:.*]] on thread T{{[0-9]+}}
15 // CHECK: tags: [[PTR_TAG:..]]/[[MEM_TAG:..]] (ptr/mem)
16 // CHECK: #0 {{[0x]+}}{{.*}}[[PC]]
17 // If we instrument using calls (default on x86), free is not the top frame
18 // of the fault. With TCO the free frame can be replaced with the interceptor.
19 // CHECK: in {{.*}}free
20 // CHECK: freed by thread {{.*}} here:
21 // CHECK: previously allocated here:
22 // CHECK: Memory tags around the buggy address (one tag corresponds to 16 bytes):
23 // CHECK: =>{{.*}}[[MEM_TAG]]
24 fprintf(stderr, "DONE\n");
25 __hwasan_disable_allocator_tagging();
26 // CHECK-NOT: DONE