First Last Prev Next    No search results available
Details
: Verifier misses malformed switch instruction
Bug#: 340
: libraries
: Core LLVM classes
Status: RESOLVED
Resolution: FIXED
: All
: All
: 1.0
: P2
: minor
: 1.3

:
: crash-on-invalid
:
:
  Show dependency tree - Show dependency graph
People
Reporter: John T. Criswell <criswell@uiuc.edu>
Assigned To: Chris Lattner <sabre@nondot.org>

Attachments
Code to reproduce the problem (1.14 KB, text/plain)
2004-05-18 14:21, John T. Criswell
Details
Reduced test case (163 bytes, text/plain)
2004-05-20 17:47, John T. Criswell
Details


Note

You need to log in before you can comment on or make changes to this bug.

Related actions


Description:   Opened: 2004-05-18 14:14
The bytecode reader seems to fail on the attached input.  I suspect that it is a
bug in the verifier, since the problem occurs from a switch statement that
selects on a uint with each possible case typed as an int

This was reported by Mark Hills:

llvm-as file.ll
opt file.bc -o null.bc
opt: /home/vadve/criswell/llvm/include/Support/Casting.h:197: typename
llvm::cast_retty<To, From>::ret_type llvm::cast(const Y&) [with X =
llvm::Constant, Y = llvm::Value*]: Assertion `isa<X>(Val) && "cast<Ty>()
argument of incompatible type!"' failed.
opt[0x861e78a]
opt[0x861e9aa]
opt[0x42029188]
opt(abort+0x16e)[0x4202a8c2]
opt[0x42022ecb]
opt(llvm::cast_retty<llvm::Constant, llvm::Value*>::ret_type
llvm::cast<llvm::Constant, llvm::Value*>(llvm::Value* const&)+0x3b)[0x83bcbd7]
opt(llvm::BytecodeParser::ParseInstruction(unsigned char const*&, unsigned char
const*, std::vector<unsigned, std::allocator<unsigned> >&,
llvm::BasicBlock*)+0x11f4)[0x83af6ec]
opt(llvm::BytecodeParser::ParseInstructionList(llvm::Function*, unsigned char
const*&, unsigned char const*)+0x2ca)[0x83b2ffc]
opt(llvm::BytecodeParser::materializeFunction(llvm::Function*)+0x58a)[0x83b3ae6]
opt(llvm::BytecodeParser::materializeModule()+0x5c)[0x83c2b76]
opt(llvm::ModuleProvider::releaseModule()+0x18)[0x83c8238]
opt(llvm::BytecodeParser::releaseModule()+0x11)[0x83c2b91]
opt(llvm::ParseBytecodeFile(std::basic_string<char, std::char_traits<char>,
std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >*)+0x39)[0x83b7b8d]
opt(main+0x6b)[0x83a5efb]
opt(__libc_start_main+0x95)[0x42017589]
opt(std::basic_ostream<char, std::char_traits<char> >& std::operator<<
<std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&,
char)+0x5d)[0x83a5de1]
Abort (core dumped)
------- Comment #1 From John T. Criswell 2004-05-18 14:21:35 -------
Created an attachment (id=118) [details]
Code to reproduce the problem

This is code from Mark that reproduces the problem.
------- Comment #2 From John T. Criswell 2004-05-20 17:47:06 -------
Created an attachment (id=119) [details]
Reduced test case

This is a reduced test case.  It is the same as the previous test case, but
isolates the problem down into the switch statement that Mark suspected was the
problem.
------- Comment #3 From Chris Lattner 2004-05-20 18:06:48 -------
Interesting.  Does the problem go away when you change the int constant to be a 
uint?  This is probably a matter of having the verifier assert that the 
constatns have the same type as the switched value... i.e. that this is 
malformed LLVM code.

-Chris
------- Comment #4 From John T. Criswell 2004-05-21 09:08:08 -------
Yes, the bug goes away when the switch selector and labels are all uints.


------- Comment #5 From Chris Lattner 2004-05-21 11:37:46 -------
Okay, then this is a verifier bug (for not catching it) and the input is 
malformed.  I'll make patch for the verifier.

-Chris
------- Comment #6 From Chris Lattner 2004-05-21 11:49:55 -------
Fixed.  Testcase here:
test/Regression/Verifier/2004-05-21-SwitchConstantMismatch.ll 

Patch here:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20040517/014436.html

-Chris

First Last Prev Next    No search results available