1// Check that sanitizers on OS X crash the process by default (i.e.
2// abort_on_error=1). See also Linux/abort_on_error.cpp.
3
4// RUN: %clangxx -DUSING_%tool_name %s -o %t
5
6// Intentionally don't inherit the default options.
7// RUN: env %tool_options='' TSAN_OPTIONS=ignore_interceptors_accesses=0 not --crash %run %t 2>&1
8
9// When we use lit's default options, we shouldn't crash.
10// RUN: not %run %t 2>&1
11
12// Leak detection isn't treated as an error so `abort_on_error=1` doesn't work.
13// UNSUPPORTED: lsan
14
15int global;
16
17int main() {
18#if defined(USING_ubsan)
19 volatile int *null = 0;
20 *null = 0;
21#else
22 volatile int *a = new int[100];
23 delete[] a;
24 global = a[0]; // use-after-free: triggers ASan/TSan report.
25#endif
26 return 0;
27}
28

source code of compiler-rt/test/sanitizer_common/TestCases/Darwin/abort_on_error.cpp