1// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s
2
3#include <stdio.h>
4#include <stdlib.h>
5
6// Required for dyld macOS 12.0+
7#if (__APPLE__)
8__attribute__((weak))
9#endif
10extern "C" void
11__asan_on_error() {
12 fprintf(stderr, format: "__asan_on_error called\n");
13 fflush(stderr);
14}
15
16int main() {
17 char *x = (char*)malloc(size: 10 * sizeof(char));
18 free(ptr: x);
19 return x[5];
20 // CHECK: __asan_on_error called
21}
22

Provided by KDAB

Privacy Policy
Improve your Profiling and Debugging skills
Find out more

source code of compiler-rt/test/asan/TestCases/on_error_callback.cpp