| 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 | |
| 10 | void *MallocViolation() { return malloc(size: 10); } |
| 11 | |
| 12 | void FreeViolation(void *Ptr) { free(ptr: Ptr); } |
| 13 | |
| 14 | void process() [[clang::nonblocking]] { |
| 15 | void *Ptr = MallocViolation(); |
| 16 | FreeViolation(Ptr); |
| 17 | } |
| 18 | |
| 19 | int 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 | |