[LLVMdev] Problem executing code with lli...
Frits van Bommel
fvbommel at wxs.nl
Thu Oct 30 04:20:39 PDT 2008
Karhu, Abhinav R wrote:
> Hi all,
> I am facing new problem with lli now. I am having a sample code in which I am doing malloc for two variables. If I compile the code with normal gcc the program runs without any warning of any sorts. If I compile the program to convert it into a bytecode file and then run it through lli it segfaults and the program aborts. This is the stack trace after execution.
> lli((anonymous namespace)::PrintStackTrace()+0x1f)[0x67cc7f]
> lli((anonymous namespace)::SignalHandler(int)+0x172)[0x67cf72]
> lli(llvm::ExecutionEngine::LoadValueFromMemory(llvm::GenericValue*, llvm::Type const*)+0x182)[0x4be4f2]
> lli(llvm::InstVisitor<llvm::Interpreter, void>::visit(llvm::Instruction&)+0x1fe)[0x4b648e]
> lli(llvm::Interpreter::runFunction(llvm::Function*, std::vector<llvm::GenericValue, std::allocator<llvm::GenericValue> > const&)+0xac)[0x4b490c]
> 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*)+0xa5)[0x4bf295]
> Segmentation fault
> I am also testing to see if the malloc was successful or not and it shows that malloc was successful.
> The part where is static memory is allocated runs fine(I am putting a print for that value). Why is the program failing in LoadValueFromMemory?
> Please some light on this issue.
First of all, you also sent this to me personally. Rest assured I'm
(obviously) on this list and if I see a problem I think I can help with
I will reply here. No need to mail me personally.
Now then, I think a problem like this is probably not easy to solve from
just a stack trace. Try reducing your program to the minimum that will
still produce the crash and (assuming you still can't see any obvious
problems in it by yourself at that point) then putting it (in .ll or .bc
form) in a problem report (through http://llvm.org/bugs/) or (if it's
small) pasting it (in .ll form) into a post to LLVM-Dev.
: I gather "bugpoint" may be of use in these situations.
: If you go the problem report route, try using the search
functionality first to see if there's already a report by someone else
on the same issue.
More information about the llvm-dev