[docs] Fix build-docs.sh
[llvm-project.git] / compiler-rt / test / hwasan / TestCases / set-error-report-callback.cpp
blobc2a20be75defcda46ed0ab0aef67872bbfcac533
1 // RUN: %clangxx_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s
3 #include <stdio.h>
4 #include <stdlib.h>
6 #include <sanitizer/hwasan_interface.h>
8 __attribute__((no_sanitize("hwaddress"))) extern "C" void callback(const char *msg) {
9 fprintf(stderr, "== error start\n%s\n== error end\n", msg);
12 int main() {
13 __hwasan_enable_allocator_tagging();
14 __hwasan_set_error_report_callback(&callback);
15 char *volatile p = (char *)malloc(16);
16 p[16] = 1;
17 free(p);
18 // CHECK: ERROR: HWAddressSanitizer:
19 // CHECK: WRITE of size 1 at
20 // CHECK: allocated here:
21 // CHECK: Memory tags around the buggy address
23 // CHECK: == error start
24 // CHECK: ERROR: HWAddressSanitizer:
25 // CHECK: WRITE of size 1 at
26 // CHECK: allocated here:
27 // CHECK: Memory tags around the buggy address
28 // CHECK: == error end