[LLVMdev] exception handling broken on x86-64?

Robert Zeh robert.a.zeh at gmail.com
Fri Mar 21 05:40:02 PDT 2008


I'm sorry to beat a dead horse, but I just want to be clear that I'm  
asking about exception handling from within the JIT, not the native  
code produced by llvm-g++.  For example, the following doesn't work  
for me on linux x86 (let alone x86_64).  I'm using an llvm build from  
revision 48493 (March 18th).

exceptiontest.cpp:
#include <stdio.h>

int main(int argc, char *argv[])
{
   try {
     throw 5;

   } catch (int i) {
     printf("caught %d\n", i);
   }
   return 0;
}

$ llvm-g++ -emit-llvm exceptiontest.cpp -c
$ lli -enable-eh -enable-correct-eh-support exceptiontest.o
terminate called after throwing an instance of 'int'
lli(_ZN40_GLOBAL__N_Signals.cpp_00000000_17C8705F15PrintStackTraceEv 
+0x24)[0x884948c]
lli(_ZN40_GLOBAL__N_Signals.cpp_00000000_17C8705F13SignalHandlerEi 
+0x115)[0x8849623]
[0xffffe420]
/lib/tls/libc.so.6(abort+0xeb)[0x4018fdbb]
/usr/lib/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv 
+0x179)[0x4010b489]
/usr/lib/libstdc++.so.6[0x40108e15]
/usr/lib/libstdc++.so.6[0x40108e52]
/usr/lib/libstdc++.so.6[0x40108fba]
[0x40307055]
lli 
(_ZN4llvm15ExecutionEngine17runFunctionAsMainEPNS_8FunctionERKSt6vectorISsSaISsEEPKPKc 
+0x41c)[0x84f7428]
lli(main+0x44b)[0x83b66d3]
/lib/tls/libc.so.6(__libc_start_main+0xd0)[0x4017bea0]
lli[0x83b61c1]
Aborted

I had hoped this would work --- and if I use llvm-g++ to compile  
exceptiontest.cpp to native code it does.  But it looks like the JIT  
is producing stack frames that the C++ runtime doesn't like.

Robert


On Mar 16, 2008, at 12:41 PM, Dale Johannesen wrote:

>
> On Mar 16, 2008, at 5:07 AM, Duncan Sands wrote:
>
>>> Did anything ever come of the work on exception handling for x86_64?
>>>
>>> I'm having problems with exceptions on linux x86_64.
>>
>> I'm fairly sure that exception handling doesn't currently work on
>> x86-64 linux (it may work with darwin - not sure).  I don't know
>> what it would take to get it to work.
>
> On Darwin, the Dwarf metadata emitted in .s/.o files is correct  
> (although there may be bugs, it hasn't been exercised beyond the  
> llvm and gcc testsuites).   The unwinding code in libgcc* has not  
> been ported to x86-64 and does not work.  Thus, if you take the  
> libgcc* from a non-llvm gcc and link llvm-gcc-produced .o files with  
> that, things work.
> It would probably not take much to get Linux x86-64 to this state, I  
> doubt the metadata is much different from Darwin.
>




More information about the llvm-dev mailing list