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

Filipe Cabecinhas via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 15 18:47:48 PDT 2016

The best option is to get a .bc file with the elements you need (but a
correct file).
What tends to happen is that you get abbreviations for most things. Then
you pause the reader on some line a bit before reading the thing you want.
Then look at the abbrev table and the abbrev you're reading, make sure they
match and note the offset in bits.
Then it's time to hex edit the file to change the abbrev at the point you
want (the instruction's MDNode) to instead point to the MDString.

Let me know if you need further help. I'll try to reproduce that problem,
but probably only tomorrow, if I can.

On Tuesday, 15 March 2016, Justin Bogner via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160315/10036db3/attachment.html>

More information about the llvm-commits mailing list