This is the mail archive of the gcc@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]

RE: Throw/Catch not working in SO?


This might be a manifestation of a problem involving different versions of the c++ support library, which includes functions used for internal run-time type identification and exception handling. If your main app is linked against one version of the support library and your shared library is linked against another, then Weird Stuff can happen.
Reported manifestations include exceptions not being caught, or SEGVs during the initial throw.

The simple solution is to just make sure the app and the lib are linked against the same version of the library (and, presumably, are built with the same C++ compiler). Unfortunately, not all of us have that luxury.

It seems to me that statically linking the support library into the shared object and then privatizing all the symbols should avoid these kinds of conflicts (and should prevent C++ ABI fragility, if the shared lib uses only a C interface), but I have been unable to get this to work. I'm still trying to figure out just what ld.so is doing to screw things up...

Hope this helps.

-rob

> -----Original Message-----
> From: Charles Y. Kim [mailto:ckim@telcontar.com]
> Sent: 14 October 2002 23:38
> To: gcc@gcc.gnu.org
> Subject: Throw/Catch not working in SO?
> 
> 
> Hi all,
> 
> I'm using some exception handling in a shared object, and while the
> throw()/catch() works in both Windows and FreeBSD (using GCC 
> 2.96), in Linux
> (GCC 3.02 --enable-shared --enable-threads=posix) the throw 
> is executed, and
> the catch never happens.
> 
> For example... let's say I have the following code in the 
> shared object...
> 
> void error() {
> 	throw(1);
> }
> 
> void error2() {
> 	error();
> }
> 
> void function() {
> 	try {
> 		if (blah)
> 			error2();
> 	}
> 	catch(...) {
> 		printf("exception caught");
> 	}
> }
> 
> I know that error2() is being called and the exception is 
> being thrown...
> but it's not being caught at all.
> 
> Does anyone have ANY ideas?
> 
> Thanks.
> 
> - Charles
> 
> 
> 


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