[PATCH] D7203: [asan] Set abort_on_error=1 by default on OS X

Kuba Brecka kuba.brecka at gmail.com
Fri Jul 24 05:13:17 PDT 2015


kubabrecka updated this revision to Diff 30569.
kubabrecka added a comment.

Addressed review comments.

> > Filipe, could you tell me on what platforms do you need to override `symbolize_vs_style`?

>  It's false on all platforms in open source.


In that case, let's remove the `config.environment['ASAN_OPTIONS'] = 'symbolize_vs_style=false'` line from open-source completely.  You can have it in your out-of-tree changes.  If we change the open-source default on Windows, we can add this back.


http://reviews.llvm.org/D7203

Files:
  lib/asan/asan_flags.inc
  lib/asan/tests/asan_test_main.cc
  test/asan/TestCases/Darwin/abort_on_error.cc
  test/asan/TestCases/Linux/abort_on_error.cc
  test/asan/lit.cfg

Index: test/asan/lit.cfg
===================================================================
--- test/asan/lit.cfg
+++ test/asan/lit.cfg
@@ -29,8 +29,11 @@
 # 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'])
Index: test/asan/TestCases/Linux/abort_on_error.cc
===================================================================
--- test/asan/TestCases/Linux/abort_on_error.cc
+++ 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}}
+}
Index: test/asan/TestCases/Darwin/abort_on_error.cc
===================================================================
--- test/asan/TestCases/Darwin/abort_on_error.cc
+++ 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}}
+}
Index: lib/asan/tests/asan_test_main.cc
===================================================================
--- lib/asan/tests/asan_test_main.cc
+++ lib/asan/tests/asan_test_main.cc
@@ -15,7 +15,13 @@
 // 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 defined(__APPLE__)
+  // 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) {
Index: lib/asan/asan_flags.inc
===================================================================
--- lib/asan/asan_flags.inc
+++ lib/asan/asan_flags.inc
@@ -78,7 +78,7 @@
 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,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7203.30569.patch
Type: text/x-patch
Size: 3667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150724/a486ef39/attachment.bin>


More information about the llvm-commits mailing list