Exception thrown from multithreaded shared lib not caught in main

Joao Luis Pinto jpinto@inescporto.pt
Sat Dec 4 06:46:00 GMT 2004


Dear all:

I'm building an executable that uses 2 shared libraries, compiled with 
-pthread. The executable is also compiled with -pthread. I'm using g++ 
version 3.3.4 (Debian testing x86).

One of the mentioned libraries function is throwing an exception (right 
at the start). This function call is surrounded by a try/catch block at 
main, that catches the particular thrown exception, all derived from 
std::exception and all unhandled (catch(...) ). The problem is that the 
exception does not reach this block, and abort is called. Here's a stack 
trace from gdb:

[Thread debugging using libthread_db enabled]
[New Thread 1077965824 (LWP 30731)]

Program received signal SIGABRT, Aborted.
[Switching to Thread 1077965824 (LWP 30731)]
0x43d4bed9 in raise () from /lib/tls/libc.so.6

(gdb) where
#0  0x43d4bed9 in raise () from /lib/tls/libc.so.6
#1  0x43d4d771 in abort () from /lib/tls/libc.so.6
#2  0x44c4c307 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5
#3  0x44c4c344 in std::terminate () from /usr/lib/libstdc++.so.5
#4  0x44c4c367 in std::terminate () from /usr/lib/libstdc++.so.5
#5  0x44c4c225 in __cxa_call_unexpected () from /usr/lib/libstdc++.so.5
#6  0x4000ec3e in Unitcommitment::read_conventional (connection=@0x0,
    longterm=true) at stl_alloc.h:242
#7  0x0804a782 in main (argc=1, argv=0x0) at main.cc:38

Any ideas on what's happening? I will be happy to provide further 
information if needed, like source code listings and g++ call transcript.

Thank you,

João Luis



More information about the Gcc-help mailing list