]> granicus.if.org Git - llvm/commitdiff
Avoid use-after-free in ~LegacyRTDyldObjectLinkingLayer
authorSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 10 Jan 2019 20:12:09 +0000 (20:12 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 10 Jan 2019 20:12:09 +0000 (20:12 +0000)
Reviewers: lhames

Subscribers: mcrosier, jlebar, bixia, llvm-commits

Differential Revision: https://reviews.llvm.org/D56521

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350886 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h

index 401f6e3fa811612cc9970e26ff20484adc9f2147..6f90f0380d95581e08531db6b1a4f907e8166c59 100644 (file)
@@ -443,11 +443,14 @@ public:
 private:
   ExecutionSession &ES;
 
-  std::map<VModuleKey, std::unique_ptr<LinkedObject>> LinkedObjects;
   ResourcesGetter GetResources;
   NotifyLoadedFtor NotifyLoaded;
   NotifyFinalizedFtor NotifyFinalized;
   NotifyFreedFtor NotifyFreed;
+
+  // NB!  `LinkedObjects` needs to be destroyed before `NotifyFreed` because
+  // `~ConcreteLinkedObject` calls `NotifyFreed`
+  std::map<VModuleKey, std::unique_ptr<LinkedObject>> LinkedObjects;
   bool ProcessAllSections = false;
 };