From 87b70fc823d37ba1185f6ccb45969d206deffbf0 Mon Sep 17 00:00:00 2001 From: Kostya Serebryany Date: Thu, 16 Oct 2014 18:59:07 +0000 Subject: [PATCH] [asan] make sure coverage is dumped even if leaks are reported llvm-svn: 219946 --- compiler-rt/lib/lsan/lsan_common.cc | 5 ++++- .../test/asan/TestCases/Linux/coverage-and-lsan.cc | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 compiler-rt/test/asan/TestCases/Linux/coverage-and-lsan.cc diff --git a/compiler-rt/lib/lsan/lsan_common.cc b/compiler-rt/lib/lsan/lsan_common.cc index 6fa070e..a89462a 100644 --- a/compiler-rt/lib/lsan/lsan_common.cc +++ b/compiler-rt/lib/lsan/lsan_common.cc @@ -451,8 +451,11 @@ void DoLeakCheck() { PrintMatchedSuppressions(); if (unsuppressed_count > 0) { param.leak_report.PrintSummary(); - if (flags()->exitcode) + if (flags()->exitcode) { + if (common_flags()->coverage) + __sanitizer_cov_dump(); internal__exit(flags()->exitcode); + } } } diff --git a/compiler-rt/test/asan/TestCases/Linux/coverage-and-lsan.cc b/compiler-rt/test/asan/TestCases/Linux/coverage-and-lsan.cc new file mode 100644 index 0000000..0f8eb78 --- /dev/null +++ b/compiler-rt/test/asan/TestCases/Linux/coverage-and-lsan.cc @@ -0,0 +1,20 @@ +// Make sure coverage is dumped even if there are reported leaks. +// +// RUN: %clangxx_asan -mllvm -asan-coverage=1 %s -o %t +// +// RUN: rm -rf %T/coverage-and-lsan +// +// RUN: mkdir -p %T/coverage-and-lsan/normal +// RUN: ASAN_OPTIONS=coverage=1:coverage_dir=%T/coverage-and-lsan:verbosity=1 not %run %t 2>&1 | FileCheck %s +// RUN: %sancov print %T/coverage-and-lsan/*.sancov 2>&1 +// +// REQUIRES: asan-64-bits + +int *g = new int; +int main(int argc, char **argv) { + g = 0; + return 0; +} + +// CHECK: LeakSanitizer: detected memory leaks +// CHECK: CovDump: -- 2.7.4