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
template <typename Container>
static void useGlobal(const Container& refCountPtrs) {
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_);
std::vector<std::unique_lock<std::mutex>> lgs_;
for (auto refCountPtr : refCountPtrs) {
lgs_.emplace_back(refCountPtr->globalMutex_);