[LLVMdev] exception handling broken on x86-64?

Robert Zeh robert.a.zeh at gmail.com
Sat Mar 15 15:23:22 PDT 2008


Did anything ever come of the work on exception handling for x86_64?

I'm having problems with exceptions on linux x86_64.  Today, on x86_64  
with a recently updated working copy of llvm, I tried calling a JITted  
function that calls an external function that throws:

thrower.cpp: (which gets compiled into a dynamic library)

extern "C"
void throwexception()
{
   throw 5;
}

My code that invokes the JIT:

     llvm::Function *q_main = implementationVisitor.m_module- 
 >getFunction("q_main");
     std::vector<GenericValue> args;
     try {
     GenericValue GV=EE->runFunction(q_main, args);
     } catch (...) {
       printf("hello!\n");

     }
   }

And instead of printing out hello I got

Program received signal SIGABRT, Aborted.
[Switching to Thread 48011952506048 (LWP 6197)]
0x00002baaa72d1765 in raise () from /lib/libc.so.6
(gdb) where
#0  0x00002baaa72d1765 in raise () from /lib/libc.so.6
#1  0x00002baaa72d31c0 in abort () from /lib/libc.so.6
#2  0x00002baaa6bcb7b4 in __gnu_cxx::__verbose_terminate_handler ()  
from /usr/lib/libstdc++.so.6
#3  0x00002baaa6bc9746 in ?? () from /usr/lib/libstdc++.so.6
#4  0x00002baaa6bc9773 in std::terminate () from /usr/lib/libstdc++.so.6
#5  0x00002baaa6bc985a in __cxa_throw () from /usr/lib/libstdc++.so.6
#6  0x00002baaa69046b7 in throwexception () from /usr/local/src/GQ/ 
libthrower.so
#7  0x00002baaa777f06d in ?? ()
#8  0x34353530372e302d in ?? ()
#9  0x0000000000000030 in ?? ()
#10 0x000000000051d7b4 in llvmImplementationVisitorTest () at main.cpp: 
365
#11 0x000000000051e06c in main (argc=1, argv=0x7fff047e0298) at  
main.cpp:389

Am I doing anything wrong?

q_main looks like this:
After pass manager:
; ModuleID = 'Q'

define void @q_main() {
entry:
	call void @throwexception( )
	ret void
}

declare void @throwexception()

declare void @abort()

		
On Feb 11, 2008, at 12:06 AM, Anton Korobeynikov wrote:

> Hello Evan and Dale,
>
>> Shootout-C++/except works for me.  Anton suggests there may be an
>> issue with the unwinding libraries and he may be right, I'll look at
>> it with you tomorrow.
> Yes. Please be sure, that you're linking with system libgcc. 
> {so,dylib},
> not with llvm-compiled one.
>
> --
> WBR, Anton Korobeynikov
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list