llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
25.93k stars 10.58k forks source link

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

Closed llvmbot closed 15 years ago

llvmbot commented 15 years ago
Bugzilla Link 3573
Resolution WORKSFORME
Resolved on Feb 13, 2009 11:19
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @asl

Extended Description

The following C program crashes when compiled with -O3 and run with lli -force-interpreter on my system:

include

include

int main(int argc, char **argv) { int number; if(argc<2) { printf("Usage: %s \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 > const&)+0xc7)[0x5be997] lli(llvm::Interpreter::callFunction(llvm::Function, std::vector<llvm::GenericValue, std::allocator > 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 > const&)+0xbc)[0x5bf35c] lli(llvm::ExecutionEngine::runFunctionAsMain(llvm::Function, std::vector<std::basic_string<char, std::char_traits, std::allocator >, std::allocator<std::basic_string<char, std::char_traits, std::allocator > > > 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

asl commented 15 years ago

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