Fix race in sync point.
Summary: The LoadDependency function does not take a lock when it runs and it could be modifying data structures while other threads are accessing it. Test Plan: Run TSAN. Reviewers: igor, sdong Reviewed By: igor, sdong Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D34095
This commit is contained in:
parent
03b432d4b8
commit
8984e5f848
@ -14,6 +14,7 @@ SyncPoint* SyncPoint::GetInstance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SyncPoint::LoadDependency(const std::vector<Dependency>& dependencies) {
|
void SyncPoint::LoadDependency(const std::vector<Dependency>& dependencies) {
|
||||||
|
std::unique_lock<std::mutex> lock(mutex_);
|
||||||
successors_.clear();
|
successors_.clear();
|
||||||
predecessors_.clear();
|
predecessors_.clear();
|
||||||
cleared_points_.clear();
|
cleared_points_.clear();
|
||||||
@ -21,6 +22,7 @@ void SyncPoint::LoadDependency(const std::vector<Dependency>& dependencies) {
|
|||||||
successors_[dependency.predecessor].push_back(dependency.successor);
|
successors_[dependency.predecessor].push_back(dependency.successor);
|
||||||
predecessors_[dependency.successor].push_back(dependency.predecessor);
|
predecessors_[dependency.successor].push_back(dependency.predecessor);
|
||||||
}
|
}
|
||||||
|
cv_.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SyncPoint::PredecessorsAllCleared(const std::string& point) {
|
bool SyncPoint::PredecessorsAllCleared(const std::string& point) {
|
||||||
|
Loading…
Reference in New Issue
Block a user