1 // RUN: %clangxx_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
2 
3 #include <stdio.h>
4 #include <stdlib.h>
5 
6 #include <sanitizer/hwasan_interface.h>
7 
8 #include "utils.h"
9 
callback(const char * msg)10 __attribute__((no_sanitize("hwaddress"))) extern "C" void callback(const char *msg) {
11   untag_fprintf(stderr, "== error start\n%s\n== error end\n", msg);
12 }
13 
main()14 int main() {
15   __hwasan_enable_allocator_tagging();
16   __hwasan_set_error_report_callback(&callback);
17   char *volatile p = (char *)malloc(16);
18   p[16] = 1;
19   free(p);
20   // CHECK: ERROR: HWAddressSanitizer:
21   // CHECK: WRITE of size 1 at
22   // CHECK: allocated here:
23   // CHECK: Memory tags around the buggy address
24 
25   // CHECK: == error start
26   // CHECK: ERROR: HWAddressSanitizer:
27   // CHECK: WRITE of size 1 at
28   // CHECK: allocated here:
29   // CHECK: Memory tags around the buggy address
30   // CHECK: == error end
31 }
32