[all-commits] [llvm/llvm-project] 4ecb2b: [DebugInfo][Metadata] Make AllEnumTypes holding Tr...
chbessonova via All-commits
all-commits at lists.llvm.org
Thu Nov 3 01:30:10 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4ecb2b8ef6be69b55d46ac274f3b7a7103219f98
https://github.com/llvm/llvm-project/commit/4ecb2b8ef6be69b55d46ac274f3b7a7103219f98
Author: Kristina Bessonova <kbessonova at accesssoftek.com>
Date: 2022-11-03 (Thu, 03 Nov 2022)
Changed paths:
A clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
M llvm/include/llvm/IR/DIBuilder.h
M llvm/lib/IR/DIBuilder.cpp
Log Message:
-----------
[DebugInfo][Metadata] Make AllEnumTypes holding TrackingMDNodeRef
Having AllEnumtypes to be a vector of TrackingMDNodeRef makes it possible
to reflect changes in metadata in the vector if they took place before DIBuilder
being finalized.
Otherwise, we end up with heap-use-after-free because AllEnumTypes contains
metadata that no longer valid.
Consider a case where we have a class containing a definition of a enum,
so this enum has the class as a scope. For some reason (doesn't matter for
the current issue), we create a temporary debug metadata for this class, and
then resolve it while finalizing CGDebugInfo.
In the case of collision during uniqifying the temporary, we then need
to replace its uses with a new pointer. If a temporary's user is unique
(this is the enum mentioned above), we may need re-uniquefying it,
which may return a new pointer in the case of another collision.
If so, the pointer we stored in AllEnumTypes vector become dangling.
Making AllEnumTypes hodling TrackingMDNodeRef should solve this problem
(see debug-info-enum-metadata-collision.cpp test for details).
Reviewed By: dblaikie
Differential Revision: https://reviews.llvm.org/D137067
More information about the All-commits
mailing list