xref: /llvm-project/compiler-rt/test/asan/TestCases/Darwin/abort_on_error.cpp (revision 673dc3d4a0b0fbb3b9b34ae2ecbfa522627fe582)
1 // Check that with empty ASAN_OPTIONS, ASan reports on OS X actually crash
2 // the process (abort_on_error=1). See also Linux/abort_on_error.cpp.
3 
4 // RUN: %clangxx_asan %s -o %t
5 
6 // Intentionally don't inherit the default ASAN_OPTIONS.
7 // RUN: env ASAN_OPTIONS="" not --crash %run %t 2>&1 | FileCheck %s
8 // When we use lit's default ASAN_OPTIONS, we shouldn't crash.
9 // RUN: not %run %t 2>&1 | FileCheck %s
10 
11 // UNSUPPORTED: ios
12 
13 #include <stdlib.h>
main()14 int main() {
15   char *x = (char*)malloc(10 * sizeof(char));
16   free(x);
17   return x[5];
18   // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
19 }
20