Index: lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc =================================================================== --- lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc +++ lib/sanitizer_common/sanitizer_symbolizer_posix_libcdep.cc @@ -470,16 +470,16 @@ // Otherwise symbolizer program is unknown, let's search $PATH CHECK(path == nullptr); - if (const char *found_path = FindPathToBinary("llvm-symbolizer")) { - VReport(2, "Using llvm-symbolizer found at: %s\n", found_path); - return new(*allocator) LLVMSymbolizer(found_path, allocator); - } #if SANITIZER_MAC if (const char *found_path = FindPathToBinary("atos")) { VReport(2, "Using atos found at: %s\n", found_path); return new(*allocator) AtosSymbolizer(found_path, allocator); } #endif // SANITIZER_MAC + if (const char *found_path = FindPathToBinary("llvm-symbolizer")) { + VReport(2, "Using llvm-symbolizer found at: %s\n", found_path); + return new(*allocator) LLVMSymbolizer(found_path, allocator); + } if (common_flags()->allow_addr2line) { if (const char *found_path = FindPathToBinary("addr2line")) { VReport(2, "Using addr2line found at: %s\n", found_path); Index: test/asan/TestCases/Helpers/crashing-function.cc =================================================================== --- /dev/null +++ test/asan/TestCases/Helpers/crashing-function.cc @@ -0,0 +1,17 @@ +// Helper source for suppressions-functions-*.cc tests: +// checking that we can suppress the failure properly in the optimized +// and unoptimized mode. +#include +#include +#include + +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(); +} Index: test/asan/TestCases/suppressions-function.cc =================================================================== --- test/asan/TestCases/suppressions-function.cc +++ /dev/null @@ -1,31 +0,0 @@ -// 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 -// RUN: %clangxx_asan -O3 %s -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s - -// FIXME: Windows symbolizer needs work to make this pass. -// XFAIL: android,win32 -// UNSUPPORTED: ios - -#include -#include -#include - -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 Index: test/asan/TestCases/suppressions-functions-optimized.cc =================================================================== --- /dev/null +++ test/asan/TestCases/suppressions-functions-optimized.cc @@ -0,0 +1,13 @@ +// RUN: echo "interceptor_via_fun:crash_function" > %t.supp +// RUN: %clangxx_asan -O3 %S/Helpers/crashing-function.cc -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s + +// FIXME: Windows symbolizer needs work to make this pass. +// 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. +// UNSUPPOERED: darwin + +// CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free +// CHECK-IGNORE: strlen ignored Index: test/asan/TestCases/suppressions-functions-unoptimized.cc =================================================================== --- /dev/null +++ test/asan/TestCases/suppressions-functions-unoptimized.cc @@ -0,0 +1,15 @@ +// 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/Helpers/crashing_function.cc -o %t && %env_asan_opts=suppressions='"%t.supp"' %run %t 2>&1 | FileCheck --check-prefix=CHECK-IGNORE %s + +// FIXME: Windows symbolizer needs work to make this pass. +// XFAIL: android,win32 +// UNSUPPORTED: ios + +// CHECK-CRASH: AddressSanitizer: heap-use-after-free +// CHECK-CRASH-NOT: strlen ignored +// CHECK-IGNORE-NOT: AddressSanitizer: heap-use-after-free +// CHECK-IGNORE: strlen ignored