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

Phabricator reviews at reviews.llvm.org
Tue Jul 28 07:34:46 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL243418: [asan] Set abort_on_error=1 by default on OS X (authored by kuba.brecka).

Changed prior to commit:
  http://reviews.llvm.org/D7203?vs=30569&id=30814#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D7203

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

Index: compiler-rt/trunk/test/asan/TestCases/Darwin/abort_on_error.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Darwin/abort_on_error.cc
+++ compiler-rt/trunk/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: compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc
===================================================================
--- compiler-rt/trunk/test/asan/TestCases/Linux/abort_on_error.cc
+++ compiler-rt/trunk/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: compiler-rt/trunk/test/asan/lit.cfg
===================================================================
--- compiler-rt/trunk/test/asan/lit.cfg
+++ compiler-rt/trunk/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: compiler-rt/trunk/lib/asan/tests/asan_test_main.cc
===================================================================
--- compiler-rt/trunk/lib/asan/tests/asan_test_main.cc
+++ compiler-rt/trunk/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) {
Index: compiler-rt/trunk/lib/asan/asan_flags.inc
===================================================================
--- compiler-rt/trunk/lib/asan/asan_flags.inc
+++ compiler-rt/trunk/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.30814.patch
Type: text/x-patch
Size: 4101 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150728/52d5cb2a/attachment.bin>


More information about the llvm-commits mailing list