[llvm] r312086 - [Orc] Fix member variable ordering issue in OrcMCJITReplacement.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 30 18:21:25 PDT 2017


The comment is an excellent idea: I've added one in r312205.

I'll have to think about the test case: This was a use-after free bug so I
think it would only reliably show up under msan.

Side note: I'm finally finding some more time to spend on the JIT APIs.
Yay! I hope this will continue -- I'd like to return to API modernization,
and hope to chat about the path forward at the Dev Meeting. :)

Cheers,
Lang.

On Tue, Aug 29, 2017 at 7:13 PM, Philip Reames <listmail at philipreames.com>
wrote:

> Clear comment?  Test case?
>
>
>
> On 08/29/2017 05:47 PM, Lang Hames via llvm-commits wrote:
>
>> Author: lhames
>> Date: Tue Aug 29 17:47:42 2017
>> New Revision: 312086
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=312086&view=rev
>> Log:
>> [Orc] Fix member variable ordering issue in OrcMCJITReplacement.
>>
>> https://reviews.llvm.org/D36888
>>
>>  From that review description:
>>
>> When an OrcMCJITReplacement object gets destructed, LazyEmitLayer may
>> still
>> contain a shared_ptr of a module, which requires ShouldDelete in the
>> deleter.
>> But ShouldDelete gets destructed before LazyEmitLayer due to the order of
>> declaration in OrcMCJITReplacement, which leads to a crash, when the
>> destructor
>> of LazyEmitLayer is executed.  Changing the order of declaration fixes
>> this.
>>
>> Patch by Moritz Kroll. Thanks Moritz!
>>
>>
>> Modified:
>>      llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
>>
>> Modified: llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Execution
>> Engine/Orc/OrcMCJITReplacement.h?rev=312086&r1=312085&r2=312086&view=diff
>> ============================================================
>> ==================
>> --- llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h (original)
>> +++ llvm/trunk/lib/ExecutionEngine/Orc/OrcMCJITReplacement.h Tue Aug 29
>> 17:47:42 2017
>> @@ -381,6 +381,9 @@ private:
>>     std::shared_ptr<JITSymbolResolver> ClientResolver;
>>     Mangler Mang;
>>   +  std::map<Module*, bool> ShouldDelete;
>> +  std::vector<std::shared_ptr<Module>> LocalModules;
>> +
>>     NotifyObjectLoadedT NotifyObjectLoaded;
>>     NotifyFinalizedT NotifyFinalized;
>>   @@ -402,8 +405,6 @@ private:
>>     std::map<ObjectLayerT::ObjHandleT, SectionAddrSet, ObjHandleCompare>
>>         UnfinalizedSections;
>>   -  std::map<Module*, bool> ShouldDelete;
>> -  std::vector<std::shared_ptr<Module>> LocalModules;
>>     std::vector<object::OwningBinary<object::Archive>> Archives;
>>   };
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170830/999fb961/attachment.html>


More information about the llvm-commits mailing list