From 15437b120c8dd3a70d857caf1c68afeeb5bad148 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 29 Jun 2017 20:15:08 +0000 Subject: [PATCH] Attempt to fix Orc JIT test timeouts I think there are some destruction ordering issues here. The ShouldDelete map seems to be getting destroyed before the shared_ptr deleter lambda accesses it. In any case, this avoids inserting elements into the map during shutdown. llvm-svn: 306736 --- lib/ExecutionEngine/Orc/OrcMCJITReplacement.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h index b20690c7caa..690276232a6 100644 --- a/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h +++ b/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h @@ -193,11 +193,11 @@ public: } auto *MPtr = M.release(); ShouldDelete[MPtr] = true; - auto Deleter = - [this](Module *Mod) { - if (ShouldDelete[Mod]) - delete Mod; - }; + auto Deleter = [this](Module *Mod) { + auto I = ShouldDelete.find(Mod); + if (I != ShouldDelete.end() && I->second) + delete Mod; + }; LocalModules.push_back(std::shared_ptr(MPtr, std::move(Deleter))); LazyEmitLayer.addModule(LocalModules.back(), &MemMgr, &Resolver); }