[C++-sig] Multiple typeinfos causing failure of exception catches
Niall Douglas
s_sourceforge at nedprod.com
Fri Jul 9 02:54:06 CEST 2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
I've been having major problems with getting exceptions to traverse
shared object boundaries with Boost.Python using GCC and Linux. There
is a core SO called libTnFOX-0.80.so which is linked against by
TnFOX.so, the BPL extension and these are linked into TestEmbedPython
which is an executable.
Now when python has an exception, I have it translate it into a C++
exception which it throws. In theory, TnFOX.so should throw a
FXPythonException instance which in theory gets caught in
TestEmbedPython. All is good under Win32, but on GCC & Linux you get
"uncaught exception" and a terminate(). I have examined the dynamic
symbol table in each binary and a typeinfo for FXPythonException
appears in TnFOX.so and TestEmbedPython.
I did some searching and found:
http://gcc.gnu.org/ml/gcc/2002-05/msg00995.html
This problem reported by Dave in 2002 is due to a typeinfo for the
exception type being emitted in each object it is used within. As
they are marked weak, they get coalesced into a single typeinfo *per*
*shared* *object* but these happily clash when multiple shared
objects are loaded.
This then causes typeinfo comparisons to fail not because the mangled
symbol is different but because the addresses of each are different.
Dave suggested a typeinfo comparison by string and AFAICS it was
refused on grounds of speed (despite that comparing hashes is the
same speed as comparing addresses).
Dave - was this problem ever fixed? If not, I will submit a patch
implementing typeinfo comparison by string comparison and we'll swing
round the roundabout once again (maybe two years of experience has
changed opinions).
BTW, your problem with python having to load extension modules with
RTDL_LOCAL rather than RTDL_GLOBAL goes away if you use my -
fvisibility=hidden patch as no symbol clashes can happen.
Cheers,
Niall
-----BEGIN PGP SIGNATURE-----
Version: idw's PGP-Frontend 4.9.6.1 / 9-2003 + PGP 8.0.2
iQA/AwUBQO3srsEcvDLFGKbPEQK7agCgsh+QzdJcz3DfHmnl9GatHlfkKY4AoMop
ymYKrY1os+JdgM5h7EG7BE/a
=N651
-----END PGP SIGNATURE-----
More information about the Cplusplus-sig
mailing list