[lld] r187670 - Use report_fatal_error() instead of llvm_unreachable() to show broken input file error.

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Aug 8 09:07:01 PDT 2013


> I don't think so. I think this is just reading a .bc file, so before
> any verifier pass is even possible, so yes, we can assert on an
> corrupted .bc file. I think we should produce fatal errors, but the
> point remain that anything reading a .bc file (including the linker
> during LTO) cannot be assumed to have only non fatal errors.

Case in point, the attached bc file causes llvm-dis to assert. The backtrace is

#0  0x0000003738635a19 in raise () from /lib64/libc.so.6
#1  0x0000003738637128 in abort () from /lib64/libc.so.6
#2  0x000000373862e986 in __assert_fail_base () from /lib64/libc.so.6
#3  0x000000373862ea32 in __assert_fail () from /lib64/libc.so.6
#4  0x00000000004d1e78 in llvm::LLVMContext::getMDKindID
(this=0x6236b0, Name=...) at
/home/espindola/llvm/llvm/lib/IR/LLVMContext.cpp:153
#5  0x00000000004e27d3 in llvm::Module::getMDKindID (this=0x624a80,
Name=...) at /home/espindola/llvm/llvm/lib/IR/Module.cpp:118
#6  0x00000000004118a2 in llvm::BitcodeReader::ParseMetadata
(this=0x624d60) at
/home/espindola/llvm/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1081
#7  0x00000000004153a8 in llvm::BitcodeReader::ParseModule
(this=0x624d60, Resume=false) at
/home/espindola/llvm/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1679
#8  0x0000000000416916 in llvm::BitcodeReader::ParseBitcodeInto
(this=0x624d60, M=0x624a80) at
/home/espindola/llvm/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:1954
#9  0x000000000041ca9f in llvm::getStreamedBitcodeModule
(name="../test.bc", streamer=0x624a00, Context=...,
ErrMsg=0x7fffffffdd40)
    at /home/espindola/llvm/llvm/lib/Bitcode/Reader/BitcodeReader.cpp:3192
#10 0x00000000004056dc in main (argc=2, argv=0x7fffffffdeb8) at
/home/espindola/llvm/llvm/tools/llvm-dis/llvm-dis.cpp:137

Not that we crash while reading, so there is no way for the verifier
to catch it. The verifier also only checks the semantic structure. The
problem in here is a flipped byte in the .bc file.

I agree that we should provide a better user experience than an assert
(or ignoring the error if they are disabled), but I don't think that
non fatal errors are the best way to do it.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.bc
Type: application/octet-stream
Size: 552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130808/2b7c9ecf/attachment.obj>


More information about the llvm-commits mailing list