• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // RUN: %clang_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
2 
3 // REQUIRES: stable-runtime
4 
5 #include <stdlib.h>
6 #include <stdio.h>
7 #include <sanitizer/hwasan_interface.h>
8 
main()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
15 // CHECK: tags: [[PTR_TAG:..]]/[[MEM_TAG:..]] (ptr/mem)
16 // CHECK: freed by thread {{.*}} here:
17 // CHECK: previously allocated here:
18 // CHECK: Memory tags around the buggy address (one tag corresponds to 16 bytes):
19 // CHECK: =>{{.*}}[[MEM_TAG]]
20   fprintf(stderr, "DONE\n");
21   __hwasan_disable_allocator_tagging();
22 // CHECK-NOT: DONE
23 }
24