summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2017-07-24 18:24:08 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2017-07-24 18:24:08 +0000
commitb5e384b31de35dea3296a55d726a724c42a1b8ef (patch)
tree468a6f71e2d43aafb152867406cbe73e766c4df4 /test
parent50bfae49ead55180ef53c2975a2c8141327cbd55 (diff)
Prefer atos to llvm-symbolizer on Darwin
atos is the default symbolizer on Apple's compiler for quite a few years now. llvm-symbolizer is quite fragile on Darwin: for example, unless a .dSYM file was explicitly generated symbolication would not work. It is also very convenient when the behavior of LLVM open source compiler matches to that of Apple's compiler on Apple's platform. Furthermore, llvm-symbolizer is not installed on Apple's platform by default, which leads to strange behavior during debugging: the test might fail under lit (where it has llvm-symbolizer) but would run properly when launched on the command line (where it does not, and atos would be used). Indeed, there's a downside: atos does not work properly with inlined functions, hence the test change. We do not think that this is a major problem, as users would often compile with -O0 when debugging, and in any case it is preferable to symbolizer not being able to symbolize. Differential Revision: https://reviews.llvm.org/D35745 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@308908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/asan/TestCases/Darwin/suppressions-function.cc28
-rw-r--r--test/asan/TestCases/suppressions-function.cc4
2 files changed, 32 insertions, 0 deletions
diff --git a/test/asan/TestCases/Darwin/suppressions-function.cc b/test/asan/TestCases/Darwin/suppressions-function.cc
new file mode 100644
index 000000000..f58796fb8
--- /dev/null
+++ b/test/asan/TestCases/Darwin/suppressions-function.cc
@@ -0,0 +1,28 @@
+// Check that without suppressions, we catch the issue.
+// RUN: %clangxx_asan -O0 %s -o %t
+// RUN: not %run %t 2>&1 | FileCheck --check-prefix=CHECK-CRASH %s
+
+// RUN: echo "interceptor_via_fun:crash_function" > %t.supp
+// RUN: %clangxx_asan -O0 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s
+
+// UNSUPPORTED: ios
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+void crash_function() {
+ char *a = (char *)malloc(6);
+ free(a);
+ size_t len = strlen(a); // BOOM
+ fprintf(stderr, "strlen ignored, len = %zu\n", len);
+}
+
+int main() {
+ crash_function();
+}
+
+// CHECK-CRASH: AddressSanitizer: heap-use-after-free
+// CHECK-CRASH-NOT: strlen ignored
+// CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free
+// CHECK-IGNORE: strlen ignored
diff --git a/test/asan/TestCases/suppressions-function.cc b/test/asan/TestCases/suppressions-function.cc
index c7f1ebe66..becefa2ee 100644
--- a/test/asan/TestCases/suppressions-function.cc
+++ b/test/asan/TestCases/suppressions-function.cc
@@ -10,6 +10,10 @@
// XFAIL: android,win32
// UNSUPPORTED: ios
+// FIXME: atos does not work for inlined functions, yet llvm-symbolizer
+// does not always work with debug info on Darwin.
+// UNSUPPORTED: darwin
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>