New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash in BitcodeReader::ParseMetadataAttachment() #5650
Comments
There is a bug in llvm::BitcodeReader::ParseMetadataAttachment(): File lib/Bitcode/Reader/BitcodeReader.cpp (SVN r85709): 1601 case bitc::METADATA_ATTACHMENT: { The loop at 1606 never ends because RecordLength is even and i is odd. This might be the root cause of this problem. See also: http://lists.cs.uiuc.edu/pipermail/llvmdev/2009-November/026880.html |
There's a check (with ugly inverted logic) on line 1603 so RecordLength cannot be even.
|
Ah you're right; sorry. On further thought, the only reason for the assertion (see stack trace below, extracted from the mailling list thread linked in Comment #1) would be the indexing of "InstructionList" with index=Record[0]. The assertion was triggered on a llvm::SmallVectorImplllvm::Instruction*, so it has to be InstructionList (another reason that it can't be line 1607/1608). 0 lli 0x0000000000feda16 |
I think I hit the same problem but I don't have access to 64-bit OS X so I can't test your bitcode file. Here's what I see: Steps to reproduce:
void d(void) { int main(int argc, char *argv[]) {
} Expected results: Actual results lli: /local/lindi/build/86985.86985/include/llvm/ADT/SmallVector.h:124: T& llvm::SmallVectorImpl::operator[](unsigned int) [with T = llvm::Instruction*]: Assertion `Begin + idx < End' failed. More info:
=> How should instructions be numbered? If you materialize "main" first then the first instruction of main will be at InstructionList[0]. My untested guess is that if you materialize "d" first then its first instruction will be InstructionList[0], right? Having the numbering depend on the order in which the functions are materialized obviously does not work since the METADATA_ATTACHMENTs refer to the instructions using some fixed numbering (which I don't yet understand, maybe it's the order in which the instructions appear in the file?). |
A workaround is to pass the --disable-lazy-compilation flag to lli, but it would still be nice to be able to lazy-load bitcode containing debug info. |
Extended Description
When called from lli, the attached bitcode file crashes in BitcodeReader::ParseMetadataAttachment().
bugpoint also crashed on OSX trying to reduce the test case:
$ Debug/bin/bugpoint -run-jit fib.bc
Read input file : 'fib.bc'
*** All input ok
Initializing execution environment: Found lli: /Users/jyasskin/src/llvm/trunk/obj/Debug/bin/lli
Running the code generator to test for a crash:
Generating reference output from raw program:
Reference output is: bugpoint.reference.out-PpLumv
*** Checking the code generator...
*** Input program does not match reference diff!
Debugging code generator problem!
Checking to see if the program is misoptimized when these functions are run through the passes: fib_left fib_right fib main
Error running tool:
/opt/local/bin/gcc -x c -fno-strict-aliasing bugpoint.safe.bc-qp2574.cbe.c -x none -shared -fPIC -o bugpoint.safe.bc-qp2574.cbe.c.dylib -O2
Undefined symbols:
"_main", referenced from:
start in crt1.10.5.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
*** Debugging code generator crash!
Checking to see if we can delete global inits:
*** Attempting to reduce the number of functions in the testcase
Checking for crash with only these functions: fib_left fib_right fib main:
Checking for crash with only these blocks: entry if.then if.end return entry if.then if.end return entry if.then... <13 total>:
Checking for crash with only 62 instructions:
*** Attempting to reduce testcase by deleting instructions: Simplification Level #1
Checking instruction: %retval = alloca i32 ; <i32*> [#uses=3]
Checking instruction: %i.addr = alloca i32 ; <i32*> [#uses=5]
Checking instruction: store i32 %i, i32* %i.addr
Checking instruction: %0 = bitcast i32* %i.addr to { }* ; <{ }> [#uses=1]invalid llvm.dbg.declare intrinsic call
call void @llvm.dbg.declare({ } null, metadata !0)
Broken module found, compilation aborted!
$ /opt/local/bin/gcc --version
i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5488)
The text was updated successfully, but these errors were encountered: