1673dc3d4SNico Weber // RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s 2673dc3d4SNico Weber 3673dc3d4SNico Weber // FIXME: Doesn't work with DLLs 4673dc3d4SNico Weber // XFAIL: win32-dynamic-asan 5673dc3d4SNico Weber 6673dc3d4SNico Weber #include <stdio.h> 7673dc3d4SNico Weber #include <stdlib.h> 8673dc3d4SNico Weber 9*0aefc946SRoy Sundahl // Required for dyld macOS 12.0+ 10*0aefc946SRoy Sundahl #if (__APPLE__) 11*0aefc946SRoy Sundahl __attribute__((weak)) 12*0aefc946SRoy Sundahl #endif 13*0aefc946SRoy Sundahl extern "C" void __asan_on_error()14*0aefc946SRoy Sundahl__asan_on_error() { 15673dc3d4SNico Weber fprintf(stderr, "__asan_on_error called\n"); 16673dc3d4SNico Weber fflush(stderr); 17673dc3d4SNico Weber } 18673dc3d4SNico Weber main()19673dc3d4SNico Weberint main() { 20673dc3d4SNico Weber char *x = (char*)malloc(10 * sizeof(char)); 21673dc3d4SNico Weber free(x); 22673dc3d4SNico Weber return x[5]; 23673dc3d4SNico Weber // CHECK: __asan_on_error called 24673dc3d4SNico Weber } 25