[PATCH] D48476: Detecting leaked instructions with metadata and freeing the metadata to avoid use-after-free
Arvīds Kokins via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 25 01:14:59 PDT 2018
akokins updated this revision to Diff 152631.
akokins added a comment.
Please ignore the previous diff, I missed that the comment didn't make sense after the changes.
https://reviews.llvm.org/D48476
Files:
lib/IR/LLVMContextImpl.cpp
Index: lib/IR/LLVMContextImpl.cpp
===================================================================
--- lib/IR/LLVMContextImpl.cpp
+++ lib/IR/LLVMContextImpl.cpp
@@ -48,6 +48,14 @@
while (!OwnedModules.empty())
delete *OwnedModules.begin();
+#ifndef NDEBUG
+ // Check for metadata references from leaked Instructions.
+ for (auto &Pair : InstructionMetadata)
+ Pair.first->dump();
+ assert(InstructionMetadata.empty() &&
+ "Instructions with metadata have been leaked");
+#endif
+
// Drop references for MDNodes. Do this before Values get deleted to avoid
// unnecessary RAUW when nodes are still unresolved.
for (auto *I : DistinctMDNodes)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48476.152631.patch
Type: text/x-patch
Size: 677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180625/ebdaf599/attachment.bin>
More information about the llvm-commits
mailing list