[PATCH] Avoid crash reading bitcode files with bad abbrev record (bug 20485)

Rafael Ávila de Espíndola rafael.espindola at gmail.com
Thu Jan 15 14:02:44 PST 2015


REPOSITORY
  rL LLVM

================
Comment at: lib/Bitcode/Reader/BitstreamReader.cpp:252
@@ +251,3 @@
+    if(!BitCodeAbbrevOp::isValidEncoding(E))
+      return true;
+
----------------
Please include a diagnostic.

================
Comment at: lib/Bitcode/Reader/BitstreamReader.cpp:302
@@ -297,3 +301,3 @@
       if (!CurBlockInfo) return true;
-      ReadAbbrevRecord();
+      if (ReadAbbrevRecord()) return true;
 
----------------
clang-format the patch please.

================
Comment at: test/Bitcode/bad-abbrev-record.txt.stderr:1
@@ +1,1 @@
+; CHECK: llvm-dis: Malformed block
----------------
Why do you need this to be in another file?

================
Comment at: test/ExecutionEngine/MCJIT/eh-lg-pic.ll:2
@@ -1,3 +1,3 @@
 ; RUN: %lli -relocation-model=pic -code-model=large %s
-; XFAIL: cygwin, win32, mingw, mips, i686, i386, aarch64, arm, asan, msan
+; XFAIL: cygwin, win32, mingw, mips, i686, i386, aarch64, arm, asan, msan, x86_64
 declare i8* @__cxa_allocate_exception(i64)
----------------
Unrelated?

================
Comment at: tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp:415
@@ +414,3 @@
+      if(Stream.ReadAbbrevRecord())
+        return Error("malformed bitcode file");
+
----------------
Ah, so you have a diagnostic here. Please move it down to where the problem is first detected. That should allow you to print a better message.

http://reviews.llvm.org/D7003

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list