summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--compiler-rt/lib/asan/asan_flags.inc2
-rw-r--r--compiler-rt/lib/asan/tests/asan_test_main.cc7
-rw-r--r--compiler-rt/test/asan/TestCases/Darwin/abort_on_error.cc17
-rw-r--r--compiler-rt/test/asan/TestCases/Linux/abort_on_error.cc18
-rw-r--r--compiler-rt/test/asan/lit.cfg7
5 files changed, 48 insertions, 3 deletions
diff --git a/compiler-rt/lib/asan/asan_flags.inc b/compiler-rt/lib/asan/asan_flags.inc
index 53a8a4039e7..40b5579da8c 100644
--- a/compiler-rt/lib/asan/asan_flags.inc
+++ b/compiler-rt/lib/asan/asan_flags.inc
@@ -78,7 +78,7 @@ ASAN_FLAG(bool, check_malloc_usable_size, true,
ASAN_FLAG(bool, unmap_shadow_on_exit, false,
"If set, explicitly unmaps the (huge) shadow at exit.")
ASAN_FLAG(
- bool, abort_on_error, false,
+ bool, abort_on_error, SANITIZER_MAC,
"If set, the tool calls abort() instead of _exit() after printing the "
"error report.")
ASAN_FLAG(bool, print_stats, false,
diff --git a/compiler-rt/lib/asan/tests/asan_test_main.cc b/compiler-rt/lib/asan/tests/asan_test_main.cc
index 53df3e716a8..5958cb8a065 100644
--- a/compiler-rt/lib/asan/tests/asan_test_main.cc
+++ b/compiler-rt/lib/asan/tests/asan_test_main.cc
@@ -11,11 +11,18 @@
//
//===----------------------------------------------------------------------===//
#include "asan_test_utils.h"
+#include "sanitizer_common/sanitizer_platform.h"
// Default ASAN_OPTIONS for the unit tests. Let's turn symbolication off to
// speed up testing (unit tests don't use it anyway).
extern "C" const char* __asan_default_options() {
+#if SANITIZER_MAC
+ // On Darwin, we default to `abort_on_error=1`, which would make tests run
+ // much slower. Let's override this and run lit tests with 'abort_on_error=0'.
+ return "symbolize=false:abort_on_error=0";
+#else
return "symbolize=false";
+#endif
}
int main(int argc, char **argv) {
diff --git a/compiler-rt/test/asan/TestCases/Darwin/abort_on_error.cc b/compiler-rt/test/asan/TestCases/Darwin/abort_on_error.cc
new file mode 100644
index 00000000000..f09718bda06
--- /dev/null
+++ b/compiler-rt/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}}
+}
diff --git a/compiler-rt/test/asan/TestCases/Linux/abort_on_error.cc b/compiler-rt/test/asan/TestCases/Linux/abort_on_error.cc
new file mode 100644
index 00000000000..264897dd9b8
--- /dev/null
+++ b/compiler-rt/test/asan/TestCases/Linux/abort_on_error.cc
@@ -0,0 +1,18 @@
+// Check that with empty ASAN_OPTIONS, ASan reports on Linux don't crash
+// the process (abort_on_error=0). See also Darwin/abort_on_error.cc.
+
+// RUN: %clangxx_asan %s -o %t
+
+// Intentionally don't inherit the default ASAN_OPTIONS.
+// RUN: ASAN_OPTIONS="" not run %t 2>&1 | FileCheck %s
+// When we use lit's default ASAN_OPTIONS, we shouldn't crash either. On Linux
+// lit doesn't set ASAN_OPTIONS anyway.
+// 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}}
+}
diff --git a/compiler-rt/test/asan/lit.cfg b/compiler-rt/test/asan/lit.cfg
index c5164713dbe..a9d57336524 100644
--- a/compiler-rt/test/asan/lit.cfg
+++ b/compiler-rt/test/asan/lit.cfg
@@ -29,8 +29,11 @@ def push_dynamic_library_lookup_path(config, new_path):
# Setup config name.
config.name = 'AddressSanitizer' + config.name_suffix
-# Setup default ASAN_OPTIONS
-config.environment['ASAN_OPTIONS'] = 'symbolize_vs_style=false'
+# Platform-specific default ASAN_OPTIONS for lit tests.
+if config.host_os == 'Darwin':
+ # On Darwin, we default to `abort_on_error=1`, which would make tests run
+ # much slower. Let's override this and run lit tests with 'abort_on_error=0'.
+ config.environment['ASAN_OPTIONS'] = 'abort_on_error=0'
# testFormat: The test format to use to interpret tests.
external_bash = (not sys.platform in ['win32'])
OpenPOWER on IntegriCloud