Strange Probleme with Exception handling

Laurent Marzullo marzullo@la-defense.oilfield.slb.com
Wed Jun 9 08:30:00 GMT 2004


Hello,

I really have a strange probleme with exception handling accross
shared library. It's working sometimes, and sometimes not.

I explain:

I've got a program 'prog' that is link together with a shared
library 'CDK'. This 'CDK' load another shared library 'plugin' 
with libtool but it's not link with this 'plugin'.

I've write an exception handler in the 'prog' that catch all
exception thrown from 'CDK' (which can also be thrown from 
'plugin').

I've declare an object 'Exception' some other one derivated from
this last one:
   - NotEnoughMemoryException
   - DataBaseException
   - OverflowException
   - ...

And in the main :

try
{
    ... some instructions ...
}
catch ( Exception& p_excp )
{
   // see below
}
catch ( std::exception& p_excp )
{
    std::cerr << p_excp.what() << '\n';
}
catch ( ... )
{
    std::cerr << "Unknown Exception\n";
}


What is really strange is that in the exception handler,
when I throw exception NotEnoughMemory the exception work
correctly and I'm able to write information about the
exception type such as 'typeid(p_excp).name()'. But, If
I throw a DataBaseException, I've got a segmentation fault
when calling 'typeid(p_excp).name()'. Both Exception are define
exactly the same way: That is

class NotEnoughMemory : public Exception
{};
class DataBaseException : public Exception
{};

Does someone already have such probleme ?
Is it a Bug ? (In this case I will submit full information as explain
in submit a bug report)

Thanks for any help
Laurent Marzullo




More information about the Gcc-help mailing list