Skip to content

Commit

Permalink
[ORC] Deallocate FinalizedAllocs on error paths in notifyEmitted.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lhames committed Mar 7, 2024
1 parent 49b1fc4 commit 4867382
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -720,14 +720,22 @@ Error ObjectLinkingLayer::notifyEmitted(MaterializationResponsibility &MR,
for (auto &P : Plugins)
Err = joinErrors(std::move(Err), P->notifyEmitted(MR));

if (Err)
if (Err) {
if (FA)
Err = joinErrors(std::move(Err), MemMgr.deallocate(std::move(FA)));
return Err;
}

if (!FA)
return Error::success();

return MR.withResourceKeyDo(
Err = MR.withResourceKeyDo(
[&](ResourceKey K) { Allocs[K].push_back(std::move(FA)); });

if (Err)
Err = joinErrors(std::move(Err), MemMgr.deallocate(std::move(FA)));

return Err;
}

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

0 comments on commit 4867382

Please sign in to comment.