Exception thrown from multithreaded shared lib not caught in main

lrtaylor@micron.com lrtaylor@micron.com
Mon Dec 6 17:45:00 GMT 2004


Is there a particular reason you're using -nostdlib when building your library:

g++ -shared -nostdlib /usr/lib/crti.o /mu/dev/gcc/3.3.1/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/crtbeginS.o  .libs/lib_func.o .libs/validation_exception.o .libs/exception.o  -Wl,--rpath -Wl,/mu/dev/gcc/3.3.1/lib/. -Wl,--rpath -Wl,/mu/dev/gcc/3.3.1/lib/. -L/mu/dev/gcc/3.3.1/lib/gcc-lib/i686-pc-linux-gnu/3.3.1 -L/mu/dev/gcc/3.3.1/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/../../.. /mu/dev/gcc/3.3.1/lib/./libstdc++.so -lm -lc -lgcc_s /mu/dev/gcc/3.3.1/lib/gcc-lib/i686-pc-linux-gnu/3.3.1/crtendS.o /usr/lib/crtn.o  -Wl,-soname -Wl,liblixo-0.1.0.so -o .libs/liblixo-0.1.0.so

In order for exceptions to be thrown across a library boundary, your library needs to be linked properly.  I suspect it's not.  Why not just let g++ determine what standard libraries to link to, etc.?  You might also try adding the argument --eh-frame-hdr which is needed for setting up stack unwinding.  I don't know if it will work the way you're doing things, though...

Thanks,
Lyle


-----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org] On Behalf Of Joao Luis Pinto
Sent: Monday, December 06, 2004 1:05 AM
To: gcc-help@gcc.gnu.org
Subject: Re: Exception thrown from multithreaded shared lib not caught in main

Hello again,

Following my previously presented problem, I have built an example that 
replicates the problem:

http://jpinto.homeip.net/~jpinto/lixo-0.1.0.tar.gz

Just run ./configure && make check

It builds a shared library with a function that throws an exception, and 
an executable that calls the library function. Aparently multi-threading 
is not the issue. The problem is that the exception is never caught in 
main(), and unhandled() gets called.

Tested with g++-3.3.4 and g++-3.4.2 (Debian testing x86).

Thank you for your time.

João Luis



More information about the Gcc-help mailing list