diff options
author | Lang Hames <lhames@gmail.com> | 2024-03-07 14:28:20 -0800 |
---|---|---|
committer | Lang Hames <lhames@gmail.com> | 2024-03-07 14:41:30 -0800 |
commit | 48673825f47cbac9cd7c61299ca8d01579314ae0 (patch) | |
tree | 6686b79e6ce7b680c500678f32f0d06125e55f16 | |
parent | 49b1fc4f831a047bd6ffde9ba19612c329dc5166 (diff) | |
download | llvm-48673825f47cbac9cd7c61299ca8d01579314ae0.zip llvm-48673825f47cbac9cd7c61299ca8d01579314ae0.tar.gz llvm-48673825f47cbac9cd7c61299ca8d01579314ae0.tar.bz2 |
[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.
-rw-r--r-- | llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp index 6ac256d..131728f 100644 --- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp +++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp @@ -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) { |