[ORC] Fix an iterator invalidation issue in JITDylib::defineMaterializing.
authorLang Hames <lhames@gmail.com>
Wed, 1 Feb 2023 01:55:29 +0000 (17:55 -0800)
committerLang Hames <lhames@gmail.com>
Wed, 1 Feb 2023 02:11:21 +0000 (18:11 -0800)
commit380355cb4c6ba28cb8b9a573591dcce694a047ee
tree2f13e0a719ff6b8e6d4aba4475201a5f6e0de988
parent6df32b8db1f0b2f1c91f3dbb62a0ced07c314aa9
[ORC] Fix an iterator invalidation issue in JITDylib::defineMaterializing.

The loop body may add and remove entries in the symbol table so we can't hold
iterators to the entries. This commit updates the method to use the newly added
NonOwningSymbolStringPtr type as keys for removal instead.

Side note: This bug has been present since the introduction of the
defineMaterializing method, but the method is called rarely and DenseMap
resizes are also rare so we didn't see any fallout until a large program was
thrown at it. There's no testcase as I haven't been able to reproduce the
failure with smaller testcases.
llvm/lib/ExecutionEngine/Orc/Core.cpp