[compiler-rt] r201304 - [asan] Avoid deadlock in CovDump.
Evgeniy Stepanov
eugeni.stepanov at gmail.com
Thu Feb 13 00:50:37 PST 2014
Author: eugenis
Date: Thu Feb 13 02:50:36 2014
New Revision: 201304
URL: http://llvm.org/viewvc/llvm-project?rev=201304&view=rev
Log:
[asan] Avoid deadlock in CovDump.
Modified:
compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc
compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage.cc
Modified: compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc?rev=201304&r1=201303&r2=201304&view=diff
==============================================================================
--- compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc (original)
+++ compiler-rt/trunk/lib/asan/lit_tests/TestCases/Linux/coverage.cc Thu Feb 13 02:50:36 2014
@@ -6,6 +6,9 @@
// RUN: %t bar 2>&1 | FileCheck %s --check-prefix=CHECK-bar
// RUN: %t foo bar 2>&1 | FileCheck %s --check-prefix=CHECK-foo-bar
// RUN: not %t foo bar 1 2 2>&1 | FileCheck %s --check-prefix=CHECK-report
+//
+// https://code.google.com/p/address-sanitizer/issues/detail?id=263
+// XFAIL: android
#include <stdio.h>
#include <string.h>
Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage.cc?rev=201304&r1=201303&r2=201304&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage.cc (original)
+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_coverage.cc Thu Feb 13 02:50:36 2014
@@ -43,9 +43,10 @@
struct CovData {
BlockingMutex mu;
InternalMmapVector<uptr> v;
+ atomic_uint32_t guard;
};
-static uptr cov_data_placeholder[sizeof(CovData) / sizeof(uptr)];
+static uptr cov_data_placeholder[(sizeof(CovData) / sizeof(uptr)) + 1];
COMPILER_CHECK(sizeof(cov_data_placeholder) >= sizeof(CovData));
static CovData *cov_data = reinterpret_cast<CovData*>(cov_data_placeholder);
@@ -65,6 +66,7 @@ static inline bool CompareLess(const upt
// Dump the coverage on disk.
void CovDump() {
#if !SANITIZER_WINDOWS
+ if (atomic_fetch_add(&cov_data->guard, 1, memory_order_relaxed) != 0) return;
BlockingMutexLock lock(&cov_data->mu);
InternalMmapVector<uptr> &v = cov_data->v;
InternalSort(&v, v.size(), CompareLess);
More information about the llvm-commits
mailing list