1 // RUN: %clangxx -fsanitize=realtime %s -o %t 2 // RUN: %env_rtsan_opts="halt_on_error=false" %run %t 2>&1 | FileCheck %s 3 4 // RUN: %clangxx -DTEST_CUSTOM_HANDLER=1 -fsanitize=realtime %s -o %t 5 // RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-CUSTOM-HANDLER 6 7 // UNSUPPORTED: ios 8 9 // Intent: Make sure we support ReporErrorSummary, including custom handlers 10 11 #include <stdio.h> 12 #include <stdlib.h> 13 14 #ifdef TEST_CUSTOM_HANDLER 15 extern "C" void __sanitizer_report_error_summary(const char *error_summary) { 16 fprintf(stderr, "%s %s\n", "In custom handler! ", error_summary); 17 } 18 #endif 19 20 int blocking_call() [[clang::blocking]] { return 0; } 21 22 int main() [[clang::nonblocking]] { 23 void *ptr = malloc(2); 24 blocking_call(); 25 26 printf("ptr: %p\n", ptr); // ensure we don't optimize out the malloc 27 } 28 29 // CHECK: SUMMARY: RealtimeSanitizer: unsafe-library-call 30 // CHECK: SUMMARY: RealtimeSanitizer: blocking-call 31 32 // CHECK-CUSTOM-HANDLER: In custom handler! SUMMARY: RealtimeSanitizer: unsafe-library-call 33