[llvm] r344956 - [ORC] Guard access to the MemMgrs vector in RTDyldObjectLinkingLayer.
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 22 14:17:56 PDT 2018
Author: lhames
Date: Mon Oct 22 14:17:56 2018
New Revision: 344956
URL: http://llvm.org/viewvc/llvm-project?rev=344956&view=rev
Log:
[ORC] Guard access to the MemMgrs vector in RTDyldObjectLinkingLayer.
Otherwise we can end up with a data-race when linking concurrently.
This should fix an intermittent failure in the multiple-compile-threads-basic.ll
testcase.
Modified:
llvm/trunk/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
Modified: llvm/trunk/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp?rev=344956&r1=344955&r2=344956&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.cpp Mon Oct 22 14:17:56 2018
@@ -121,8 +121,15 @@ void RTDyldObjectLinkingLayer::emit(Mate
}
auto K = R.getVModuleKey();
- MemMgrs.push_back(GetMemoryManager());
- auto &MemMgr = *MemMgrs.back();
+ RuntimeDyld::MemoryManager *MemMgr = nullptr;
+
+ // Create a record a memory manager for this object.
+ {
+ auto Tmp = GetMemoryManager();
+ std::lock_guard<std::mutex> Lock(RTDyldLayerMutex);
+ MemMgrs.push_back(std::move(Tmp));
+ MemMgr = MemMgrs.back().get();
+ }
JITDylibSearchOrderResolver Resolver(*SharedR);
@@ -134,7 +141,7 @@ void RTDyldObjectLinkingLayer::emit(Mate
* duplicate defs.
*/
jitLinkForORC(
- **Obj, std::move(O), MemMgr, Resolver, ProcessAllSections,
+ **Obj, std::move(O), *MemMgr, Resolver, ProcessAllSections,
[this, K, SharedR, &Obj, InternalSymbols](
std::unique_ptr<RuntimeDyld::LoadedObjectInfo> LoadedObjInfo,
std::map<StringRef, JITEvaluatedSymbol> ResolvedSymbols) {
More information about the llvm-commits
mailing list