33 lines · cpp
1// RUN: %clangxx -fsanitize=realtime %s -o %t2// RUN: %env_rtsan_opts="halt_on_error=false" %run %t 2>&1 | FileCheck %s3 4// RUN: %clangxx -DTEST_CUSTOM_HANDLER=1 -fsanitize=realtime %s -o %t5// RUN: not %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-CUSTOM-HANDLER6 7// UNSUPPORTED: ios8 9// Intent: Make sure we support ReporErrorSummary, including custom handlers10 11#include <stdio.h>12#include <stdlib.h>13 14#ifdef TEST_CUSTOM_HANDLER15extern "C" void __sanitizer_report_error_summary(const char *error_summary) {16 fprintf(stderr, "%s %s\n", "In custom handler! ", error_summary);17}18#endif19 20int blocking_call() [[clang::blocking]] { return 0; }21 22int 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 malloc27}28 29// CHECK: SUMMARY: RealtimeSanitizer: unsafe-library-call30// CHECK: SUMMARY: RealtimeSanitizer: blocking-call31 32// CHECK-CUSTOM-HANDLER: In custom handler! SUMMARY: RealtimeSanitizer: unsafe-library-call33