[llvm] c1baf94 - [ORC] Avoid invalidating iterators in EHFrameRegistrationPlugin.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Sun May 2 12:30:54 PDT 2021
Was this covered by existing tests/found by a novel UB failure on a
buildbot or the like?
On Sun, Apr 25, 2021 at 6:04 PM Lang Hames via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
>
> Author: Lang Hames
> Date: 2021-04-25T16:55:19-07:00
> New Revision: c1baf946e6cf611ae871e34db5cfea0f94f4b5a0
>
> URL:
> https://github.com/llvm/llvm-project/commit/c1baf946e6cf611ae871e34db5cfea0f94f4b5a0
> DIFF:
> https://github.com/llvm/llvm-project/commit/c1baf946e6cf611ae871e34db5cfea0f94f4b5a0.diff
>
> LOG: [ORC] Avoid invalidating iterators in EHFrameRegistrationPlugin.
>
> In EHFrameRegistrationPlugin::notifyTransferringResources if SrcKey had
> eh-frames associated but DstKey did not we would create a new entry for
> DskKey,
> invalidating the iterator for SrcKey in the process. This commit fixes
> that by
> removing SrcKey first in this case.
>
> Added:
>
>
> Modified:
> llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff --git a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
> b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
> index dc3cf87798cf..ccac4b8c545b 100644
> --- a/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
> +++ b/llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
> @@ -654,13 +654,23 @@ Error
> EHFrameRegistrationPlugin::notifyRemovingResources(ResourceKey K) {
> void EHFrameRegistrationPlugin::notifyTransferringResources(
> ResourceKey DstKey, ResourceKey SrcKey) {
> auto SI = EHFrameRanges.find(SrcKey);
> - if (SI != EHFrameRanges.end()) {
> + if (SI == EHFrameRanges.end())
> + return;
> +
> + auto DI = EHFrameRanges.find(DstKey);
> + if (DI != EHFrameRanges.end()) {
> auto &SrcRanges = SI->second;
> - auto &DstRanges = EHFrameRanges[DstKey];
> + auto &DstRanges = DI->second;
> DstRanges.reserve(DstRanges.size() + SrcRanges.size());
> for (auto &SrcRange : SrcRanges)
> DstRanges.push_back(std::move(SrcRange));
> EHFrameRanges.erase(SI);
> + } else {
> + // We need to move SrcKey's ranges over without invalidating the SI
> + // iterator.
> + auto Tmp = std::move(SI->second);
> + EHFrameRanges.erase(SI);
> + EHFrameRanges[DstKey] = std::move(Tmp);
> }
> }
>
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://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/20210502/2b3b06fd/attachment.html>
More information about the llvm-commits
mailing list