Commit e370385a authored by Robin Cheng's avatar Robin Cheng Committed by Facebook GitHub Bot

Fix a singleton at fork race?

Summary: Why is unsafeGetUnlocked() used here? It seems obviously not safe when we're iterating on the vector after. Am I missing something?

Reviewed By: andriigrynenko

Differential Revision: D27748519

fbshipit-source-id: fe8a78408fdf59e83f5261740e4703f876ad9f9d
parent a3c1fac8
...@@ -209,13 +209,13 @@ SingletonVault::SingletonVault(Type type) noexcept : type_(type) { ...@@ -209,13 +209,13 @@ SingletonVault::SingletonVault(Type type) noexcept : type_(type) {
this, this,
/*prepare*/ /*prepare*/
[this]() { [this]() {
const auto& singletons = singletons_.unsafeGetUnlocked(); auto singletons = singletons_.rlock();
const auto& creationOrder = creationOrder_.unsafeGetUnlocked(); auto creationOrder = creationOrder_.rlock();
CHECK_GE(singletons.size(), creationOrder.size()); CHECK_GE(singletons->size(), creationOrder->size());
for (const auto& singletonType : creationOrder) { for (const auto& singletonType : *creationOrder) {
liveSingletonsPreFork_.insert(singletons.at(singletonType)); liveSingletonsPreFork_.insert(singletons->at(singletonType));
} }
return true; return true;
......
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