[PATCH] D36888: [ORC] Fix crash in ~OrcMCJITReplacement when modules are not removed.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 29 13:08:29 PDT 2017
On Tue, Aug 29, 2017 at 1:04 PM Lang Hames <lhames at gmail.com> wrote:
> Hi Dave,
>
> Isn't that what the proposed patch is doing? The pointers were already
> shared.
>
Ah, yeah - I misread the patch, saw lines that added shared_ptrs and
thought the ownership was being changed.
Nevermind, carry on.
>
> (Side note: The ShouldDelete nonsense is there because of MCJIT's absurd
> ownership semantics addModule takes a unique_ptr, but removeModule releases
> it rather than deleting it.)
>
> Cheers,
> Lang.
>
> On Mon, Aug 28, 2017 at 8:27 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Could the member variables be reordered instead? Placing ShouldDelete
>> before LazyEmitLayer?
>>
>> That seems simpler/better (less complicated ownership, etc) than moving
>> to shared ownership?
>>
>> On Fri, Aug 18, 2017 at 11:41 AM Moritz Kroll via Phabricator via
>> llvm-commits <llvm-commits at lists.llvm.org> wrote:
>>
>>> mkroll-nv created this revision.
>>>
>>> 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.
>>>
>>>
>>> https://reviews.llvm.org/D36888
>>>
>>> Files:
>>> lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
>>>
>>>
>>> Index: lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
>>> ===================================================================
>>> --- lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
>>> +++ lib/ExecutionEngine/Orc/OrcMCJITReplacement.h
>>> @@ -381,6 +381,9 @@
>>> 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 @@
>>> 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/20170829/a0f22afd/attachment.html>
More information about the llvm-commits
mailing list