<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - lli crashes with va_arg when using -force-interpreter=true"
   href="http://llvm.org/bugs/show_bug.cgi?id=21197">21197</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>lli crashes with va_arg when using -force-interpreter=true
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>willem_llvm_bugs@lekkertech.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=13164" name="attach_13164" title="Simple vaarg example.">attachment 13164</a> <a href="attachment.cgi?id=13164&action=edit" title="Simple vaarg example.">[details]</a></span>
Simple vaarg example.

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 (<a href="http://llvm.org/">http://llvm.org/</a>):
  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::allocator<llvm::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<char>,
std::__1::allocator<char> >, std::__1::allocator<std::__1::basic_string<char,
std::__1::char_traits<char>, std::__1::allocator<char> > > > const&, char
const* const*) + 1521
8  lli                      0x000000010651c703
9  libdyld.dylib            0x00007fff8fa3c5fd start + 1
Stack dump:
0.    Program arguments: /usr/local/Cellar/llvm/3.5.0/bin/lli
-force-interpreter=true ./vaarg.ll 
Segmentation fault: 11</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>