Skip to content

Commit 4867382

Browse files
committed
[ORC] Deallocate FinalizedAllocs on error paths in notifyEmitted.
If notifyEmitted encounters a failure (either because some plugin returned one, or because the ResourceTracker was defunct) then we need to deallocate the FinalizedAlloc manually. No testcase yet: This requires a concurrent setup -- we'll need to build some infrastructure to coordinate links and deliberately injected failures in order to reliably test this.
1 parent 49b1fc4 commit 4867382

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,14 +720,22 @@ Error ObjectLinkingLayer::notifyEmitted(MaterializationResponsibility &MR,
720720
for (auto &P : Plugins)
721721
Err = joinErrors(std::move(Err), P->notifyEmitted(MR));
722722

723-
if (Err)
723+
if (Err) {
724+
if (FA)
725+
Err = joinErrors(std::move(Err), MemMgr.deallocate(std::move(FA)));
724726
return Err;
727+
}
725728

726729
if (!FA)
727730
return Error::success();
728731

729-
return MR.withResourceKeyDo(
732+
Err = MR.withResourceKeyDo(
730733
[&](ResourceKey K) { Allocs[K].push_back(std::move(FA)); });
734+
735+
if (Err)
736+
Err = joinErrors(std::move(Err), MemMgr.deallocate(std::move(FA)));
737+
738+
return Err;
731739
}
732740

733741
Error ObjectLinkingLayer::handleRemoveResources(JITDylib &JD, ResourceKey K) {

0 commit comments

Comments
 (0)