This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

terminate called after throwing an exception from a shared library


Hi All,

I'm having a horrific time getting exception handling to work in my
C++ application which consists of an executable and three dynamic
shared libraries.  Library A defines the various exception classes.
Library B throws one of these exception classes, and the executable
attempts to catch them, however instead of catching the exception, the
program exits by calling the terminate handler.  I realize from the
gcc manual that this has something to do with the exception type
defined in my shared library not being recognized in the program that
tries to catch it.  I have not messed with any of the visibility
attributes.  I'm assuming that all symbols are exported by default.

I have scoured the Internet looking for answers.  As far as I know I
am doing all the right stuff for this to be working.

My application is running on Debian Linux (Lenny) 2.6.34.  My gcc
version is 4.4.3:

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian
4.4.2-9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--enable-shared --enable-multiarch --enable-linker-build-id
--with-system-zlib --libexecdir=/usr/lib --without-included-gettext
--enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4
--program-suffix=-4.4 --enable-nls --enable-clocale=gnu
--enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i486
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 20100108 (prerelease) (Debian 4.4.2-9)


I'm building each of my shared libraries with the following options:

gcc -fPIC -shared -shared-libgcc -rdynamic -W1,--export-dynamic
-Wl,-soname,libfoundation.so -o lib/libfoundation.so $(OBJECTS) -ldl

My executable is built with these options:

gcc -Wall -g -shared-libgcc

When I try to run my application, it exits with the following error message:

terminate called after throwing an instance of
'Execution::TEventHandle<Execution::EventBody>'

I most definitely have a catch handler defined for this exception,
which does work when exceptions of this type are thrown from within my
executable program.  When thrown from a shared library, the exception
is not recognized and terminate() is called.

Can anyone see what I might be doing wrong?

Thanks in advance!

Dallas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]