[PATCH] Bitcode: Error out instead of crashing on corrupt metadata

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 17:27:43 PDT 2016


I hit a crash in the bitcode reader on some corrupt input where an
MDString had somehow been attached to an instruction instead of an
MDNode. This input is pretty bogus, but we shouldn't be crashing on bad
input here.

The attached patch adds error handling in all of the places where we
currently have unchecked casts from Metadata to MDNode, which means
we'll error out instead of crashing for that sort of input.

Unfortunately, I can't figure out a way to write a test to hit these
corner cases. Tips on generating bogus bitcode would be welcome.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: bitcode-reader-metadata-attachments.patch
Type: text/x-patch
Size: 6909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160315/ad9f86c0/attachment.bin>


More information about the llvm-commits mailing list