[PATCH] D7203: [asan] Set abort_on_error=1 by default on OS X
Kuba Brecka
kuba.brecka at gmail.com
Tue Jul 21 05:32:25 PDT 2015
kubabrecka retitled this revision from "[compiler-rt] Turn abort_on_error=1 by default on OS X (part 1/2)" to "[asan] Set abort_on_error=1 by default on OS X".
kubabrecka updated the summary for this revision.
kubabrecka added reviewers: samsonov, glider.
kubabrecka updated this revision to Diff 30247.
kubabrecka added a comment.
Hi everyone, I'd like to (once again) reopen this topic. A recent change introduced "default flags for lit tests", so this patch can be simplified and we don't need to modify any test.
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-darwin.cc
test/asan/TestCases/Linux/abort_on_error-linux.cc
test/asan/lit.cfg
Index: test/asan/lit.cfg
===================================================================
--- test/asan/lit.cfg
+++ test/asan/lit.cfg
@@ -30,7 +30,7 @@
config.name = 'AddressSanitizer' + config.name_suffix
# Setup default ASAN_OPTIONS
-config.environment['ASAN_OPTIONS'] = 'symbolize_vs_style=false'
+config.environment['ASAN_OPTIONS'] = 'symbolize_vs_style=false: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-linux.cc
===================================================================
--- test/asan/TestCases/Linux/abort_on_error-linux.cc
+++ test/asan/TestCases/Linux/abort_on_error-linux.cc
@@ -0,0 +1,16 @@
+// 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-darwin.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
+
+#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}}
+ // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
+}
Index: test/asan/TestCases/Darwin/abort_on_error-darwin.cc
===================================================================
--- test/asan/TestCases/Darwin/abort_on_error-darwin.cc
+++ test/asan/TestCases/Darwin/abort_on_error-darwin.cc
@@ -0,0 +1,16 @@
+// 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-linux.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
+
+#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}}
+ // CHECK: {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}
+}
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,7 @@
// 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() {
- return "symbolize=false";
+ return "symbolize=false:abort_on_error=0";
}
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 == 1),
"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.30247.patch
Type: text/x-patch
Size: 3114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150721/c9672410/attachment.bin>
More information about the llvm-commits
mailing list