aboutsummaryrefslogtreecommitdiff
path: root/test/asan/TestCases/Darwin/abort_on_error.cc
diff options
context:
space:
mode:
Diffstat (limited to 'test/asan/TestCases/Darwin/abort_on_error.cc')
-rw-r--r--test/asan/TestCases/Darwin/abort_on_error.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/asan/TestCases/Darwin/abort_on_error.cc b/test/asan/TestCases/Darwin/abort_on_error.cc
new file mode 100644
index 000000000000..f09718bda06e
--- /dev/null
+++ b/test/asan/TestCases/Darwin/abort_on_error.cc
@@ -0,0 +1,17 @@
+// Check that with empty ASAN_OPTIONS, ASan reports on OS X actually crash
+// the process (abort_on_error=1). See also Linux/abort_on_error.cc.
+
+// RUN: %clangxx_asan %s -o %t
+
+// Intentionally don't inherit the default ASAN_OPTIONS.
+// RUN: ASAN_OPTIONS="" not --crash %run %t 2>&1 | FileCheck %s
+// When we use lit's default ASAN_OPTIONS, we shouldn't crash.
+// RUN: not %run %t 2>&1 | FileCheck %s
+
+#include <stdlib.h>
+int main() {
+ char *x = (char*)malloc(10 * sizeof(char));
+ free(x);
+ return x[5];
+ // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
+}