Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race conditions in the PluginSystem #32359

Merged
merged 1 commit into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion FWCore/PluginManager/interface/PluginFactoryBase.h
Expand Up @@ -61,7 +61,7 @@ namespace edmplugin {
std::atomic<void*> m_ptr;
};

typedef tbb::concurrent_vector<PluginMakerInfo> PMakers;
typedef tbb::concurrent_vector<PluginMakerInfo, tbb::zero_allocator<PluginMakerInfo>> PMakers;
typedef tbb::concurrent_unordered_map<std::string, PMakers> Plugins;

// ---------- const member functions ---------------------
Expand Down
4 changes: 4 additions & 0 deletions FWCore/PluginManager/src/PluginFactoryBase.cc
Expand Up @@ -75,6 +75,10 @@ namespace edmplugin {
<< "'\n but was not there. This means the plugin cache is incorrect. Please run 'EdmPluginRefresh " << lib
<< "'";
}
//The item in the container can still be under construction so wait until the m_ptr has been set since that is done last
auto const& value = itFound->second.front();
while (value.m_ptr.load(std::memory_order_acquire) == nullptr) {
}
} else {
//The item in the container can still be under construction so wait until the m_ptr has been set since that is done last
auto const& value = itFound->second.front();
Expand Down
2 changes: 1 addition & 1 deletion FWCore/PluginManager/src/PluginManager.cc
Expand Up @@ -251,7 +251,7 @@ namespace edmplugin {
throw;
}
}
loadables_[p] = ptr;
loadables_.emplace(p, ptr);
justLoaded_(*ptr);
return *ptr;
}
Expand Down