From: Sanjoy Das Date: Thu, 10 Jan 2019 20:12:09 +0000 (+0000) Subject: Avoid use-after-free in ~LegacyRTDyldObjectLinkingLayer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ec5ab87c7698f6ede8905f833db67cd16449e360;p=llvm Avoid use-after-free in ~LegacyRTDyldObjectLinkingLayer 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 --- diff --git a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h index 401f6e3fa81..6f90f0380d9 100644 --- a/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h +++ b/include/llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h @@ -443,11 +443,14 @@ public: private: ExecutionSession &ES; - std::map> LinkedObjects; ResourcesGetter GetResources; NotifyLoadedFtor NotifyLoaded; NotifyFinalizedFtor NotifyFinalized; NotifyFreedFtor NotifyFreed; + + // NB! `LinkedObjects` needs to be destroyed before `NotifyFreed` because + // `~ConcreteLinkedObject` calls `NotifyFreed` + std::map> LinkedObjects; bool ProcessAllSections = false; };