Commit 1d11ad7a authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Fix TLRefCount::useGlobal to work with TSAN

Summary: TSAN has a limitation for the number of locks held concurrently - https://github.com/llvm-mirror/compiler-rt/blob/master/lib/sanitizer_common/sanitizer_deadlock_detector.h#L126, so we have to work around that.

Reviewed By: yfeldblum

Differential Revision: D4866477

fbshipit-source-id: 958251e97d91c1c46ef4e907de2cf189fb04f88e
parent 42f6e99c
......@@ -87,6 +87,17 @@ class TLRefCount {
template <typename Container>
static void useGlobal(const Container& refCountPtrs) {
#ifdef FOLLY_SANITIZE_THREAD
// TSAN has a limitation for the number of locks held concurrently, so it's
// safer to call useGlobal() serially.
if (refCountPtrs.size() > 1) {
for (auto refCountPtr : refCountPtrs) {
refCountPtr->useGlobal();
}
return;
}
#endif
std::vector<std::unique_lock<std::mutex>> lgs_;
for (auto refCountPtr : refCountPtrs) {
lgs_.emplace_back(refCountPtr->globalMutex_);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment