llvm-project
llvm-project copied to clipboard
lli crashes with va_arg when using -force-interpreter=true
Bugzilla Link | 21197 |
Version | unspecified |
OS | MacOS X |
Attachments | Simple vaarg example. |
Reporter | LLVM Bugzilla Contributor |
Extended Description
When compiling the attached example to bitcode and running it with lli -force-interpreter=true lli crashes. Compiling and running it natively yields the correct output and running it through lli without -force-interpreter=true also yields the expected output.
From running the example with lli -debug and cross checking with the llvm ir, it seems that the va_start implementation used by the interpreter does not initialize the __va_list_tag structure correctly, but I do not know what the correct initialization would look like. (And the crash might have a different cause al to gether).
users-Mac:test user$clang -O0 -emit-llvm -S vaarg.c
vaarg.c:12:2: warning: implicit declaration of function 'putchar' is invalid in C99 [-Wimplicit-function-declaration]
putchar('0' + i);
^
1 warning generated.
users-Mac:test user$ /usr/local/Cellar/llvm/3.5.0/bin/lli --version
LLVM (http://llvm.org/):
LLVM version 3.5.0
Optimized build with assertions.
Built Sep 21 2014 (23:54:15).
Default target: x86_64-apple-darwin13.4.0
Host CPU: core-avx-i
users-Mac:test user$ /usr/local/Cellar/llvm/3.5.0/bin/lli -force-interpreter=false ./vaarg.ll
2
users-Mac:test user$ /usr/local/Cellar/llvm/3.5.0/bin/lli -force-interpreter=true ./vaarg.ll
0 libLLVM-3.5.dylib 0x0000000106cb4bb9 llvm::sys::PrintStackTrace(__sFILE) + 40
1 libLLVM-3.5.dylib 0x0000000106cb4fa4 SignalHandler(int) + 248
2 libsystem_platform.dylib 0x00007fff94e045aa _sigtramp + 26
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 1797241456
4 libLLVM-3.5.dylib 0x000000010699d66e llvm::Interpreter::visitLoadInst(llvm::LoadInst&) + 156
5 libLLVM-3.5.dylib 0x00000001069a640c llvm::Interpreter::run() + 156
6 libLLVM-3.5.dylib 0x00000001069a9f04 llvm::Interpreter::runFunction(llvm::Function*, std::__1::vector<llvm::GenericValue, std::__1::allocatorllvm::GenericValue > const&) + 240
7 libLLVM-3.5.dylib 0x00000001068f1c81 llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::__1::vector<std::__1::basic_string<char, std::__1::char_traits
This happens on latest as well. Does anybody have fix for it ? Thanks