Mercurial > hg > CbC > CbC_llvm
view compiler-rt/test/hwasan/TestCases/set-error-report-callback.cpp @ 221:79ff65ed7e25
LLVM12 Original
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 15 Jun 2021 19:15:29 +0900 |
parents | |
children | 1f2b6ac9f198 |
line wrap: on
line source
// RUN: %clangxx_hwasan %s -o %t && not %run %t 2>&1 | FileCheck %s #include <stdio.h> #include <stdlib.h> #include <sanitizer/hwasan_interface.h> __attribute__((no_sanitize("hwaddress"))) extern "C" void callback(const char *msg) { fprintf(stderr, "== error start\n%s\n== error end\n", msg); } int main() { __hwasan_enable_allocator_tagging(); __hwasan_set_error_report_callback(&callback); char *volatile p = (char *)malloc(16); p[16] = 1; free(p); // CHECK: ERROR: HWAddressSanitizer: // CHECK: WRITE of size 1 at // CHECK: allocated here: // CHECK: Memory tags around the buggy address // CHECK: == error start // CHECK: ERROR: HWAddressSanitizer: // CHECK: WRITE of size 1 at // CHECK: allocated here: // CHECK: Memory tags around the buggy address // CHECK: == error end }