Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

lli crash -force-interpreter and stdlib function calls #3963

Closed Quuxplusone closed 15 years ago

Quuxplusone commented 15 years ago
Bugzilla Link PR3573
Status RESOLVED WORKSFORME
Importance P normal
Reported by Daniel Reynaud (reynaudd@loria.fr)
Reported on 2009-02-13 10:40:44 -0800
Last modified on 2009-02-13 11:19:20 -0800
Version unspecified
Hardware PC Linux
CC anton@korobeynikov.info, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
The following C program crashes when compiled with -O3 and run with lli -force-
interpreter on my system:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
    int number;
    if(argc<2) {
        printf("Usage: %s <number>\n", argv[0]);
        exit(1);
    }

// other calls such as atof also provoke the crash
    number = atoi(argv[1]);
    printf("hello %d\n", number);
}

Steps to reproduce the crash:

~/test/llvm$ llvm-gcc -emit-llvm -O3 -c hello.c -o hello.bc
~/test/llvm$ lli -force-interpreter hello.bc 42
lli: /tmp/buildd/llvm-2.2/lib/Support/APInt.cpp:109: llvm::APInt::APInt(const
llvm::APInt&): Assertion `BitWidth <= MAX_INT_BITS && "bitwidth too large"'
failed.
lli[0x843d88]
/lib/libc.so.6[0x7f6f3b9daf60]
/lib/libc.so.6(gsignal+0x35)[0x7f6f3b9daed5]
/lib/libc.so.6(abort+0x183)[0x7f6f3b9dc3f3]
/lib/libc.so.6(__assert_fail+0xe9)[0x7f6f3b9d3dc9]
lli(llvm::APInt::APInt(llvm::APInt const&)+0xc3)[0x820773]
lli(llvm::Interpreter::callExternalFunction(llvm::Function*,
std::vector<llvm::GenericValue, std::allocator<llvm::GenericValue> >
const&)+0xc7)[0x5be997]
lli(llvm::Interpreter::callFunction(llvm::Function*,
std::vector<llvm::GenericValue, std::allocator<llvm::GenericValue> >
const&)+0x55f)[0x5b6adf]
lli(llvm::Interpreter::visitCallSite(llvm::CallSite)+0x22e)[0x5b86ce]
lli(llvm::InstVisitor<llvm::Interpreter,
void>::visit(llvm::Instruction&)+0xa6)[0x5c22b6]
lli(llvm::Interpreter::run()+0x61)[0x5b92a1]
lli(llvm::Interpreter::runFunction(llvm::Function*,
std::vector<llvm::GenericValue, std::allocator<llvm::GenericValue> >
const&)+0xbc)[0x5bf35c]
lli(llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*,
std::vector<std::basic_string<char, std::char_traits<char>,
std::allocator<char> >, std::allocator<std::basic_string<char,
std::char_traits<char>, std::allocator<char> > > > const&, char const*
const*)+0x497)[0x5c89d7]
lli(main+0x21d)[0x4b362d]
/lib/libc.so.6(__libc_start_main+0xe6)[0x7f6f3b9c71a6]
lli(std::ios_base::Init::~Init()+0x41)[0x4b2ec9]
Aborted

The program runs correctly without -force-interpreter, without -emit-llvm and
with -O0.

Configuration info (llvm was obtained with apt-get):

~/test/llvm$ lli --version
Low Level Virtual Machine (http://llvm.org/):
  llvm version 2.2 (Debian 2.2-12)
  Optimized build with assertions.

~/test/llvm$ uname -a
Linux XXX 2.6.26-1-amd64 #1 SMP Sat Jan 10 17:57:00 UTC 2009 x86_64 GNU/Linux
Quuxplusone commented 15 years ago

2.2 is really ancient version. TOT correctly reports lack of interpreter support for external function atoi