1// RUN: %clangxx -fsanitize=realtime %s -o %t
2// RUN: %env_rtsan_opts="halt_on_error=true" not %run %t 2>&1 | FileCheck %s
3// RUN: %env_rtsan_opts="halt_on_error=false" %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK-NO-HALT,CHECK
4// UNSUPPORTED: ios
5
6// Intent: Ensure that halt_on_error does not exit on the first violation.
7
8#include <stdlib.h>
9
10void *MallocViolation() { return malloc(size: 10); }
11
12void FreeViolation(void *Ptr) { free(ptr: Ptr); }
13
14void process() [[clang::nonblocking]] {
15 void *Ptr = MallocViolation();
16 FreeViolation(Ptr);
17}
18
19int main() {
20 process();
21 return 0;
22 // CHECK: ==ERROR: RealtimeSanitizer
23 // CHECK-NEXT: {{.*`malloc`.*}}
24 // CHECK-NO-HALT: ==ERROR: RealtimeSanitizer
25 // CHECK-NO-HALT-NEXT: {{.*`free`.*}}
26}
27

source code of compiler-rt/test/rtsan/halt_on_error.cpp