Commit 96b30363 authored by Chris Keeline's avatar Chris Keeline Committed by Facebook GitHub Bot

Fix dev-tsan error

Summary:
TSAN catches this as a data race, though it's fairly benign. In the
assert we read non-atomic `state` without holding the lock. As a fix, acquire
the lock in the assert. The assert is skipped anyway in opt builds.

Reviewed By: yfeldblum

Differential Revision: D28302491

fbshipit-source-id: b92ca9f3d321d34301d96e59fab363d999bddb30
parent e75e8829
...@@ -173,7 +173,10 @@ void TimedRWMutexImpl<ReaderPriority, BatonType>::lock_shared() { ...@@ -173,7 +173,10 @@ void TimedRWMutexImpl<ReaderPriority, BatonType>::lock_shared() {
read_waiters_.push_back(waiter); read_waiters_.push_back(waiter);
ulock.unlock(); ulock.unlock();
waiter.baton.wait(); waiter.baton.wait();
if (folly::kIsDebug) {
std::unique_lock<folly::SpinLock> assertLock{lock_};
assert(state_ == State::READ_LOCKED); assert(state_ == State::READ_LOCKED);
}
return; return;
} }
assert( assert(
......
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