On 26/03/2013 18:51, Holger Joukl wrote:
Hi,
I'm wrapping a C++ library that's actually just a thin wrapper around a C
lib.
Through a dispatch() method of a Dispatcher class there's an invocation of
callbacks which get implemented on the Python side, by subclassing callback
classes exposed through Boost.Python.
Now, for performing the actual dispatch the C++ library calls into the
underlying C library.
This hasn't been a problem so far as we've been targetting Solaris using
Sun/Oracle studio
compilers.
However, on Linux compiled with GCC, if an exception gets raised in the
Python callback the
program segfaults. Obviously the C part of the vendor library has not been
compiled with
(GCC-) exception support for Linux.
Unfortunately this isn't under my control and the library provider seems
not to be willing
to make the library robust against exceptions in user callback code.
So I need to keep the Boost C++ exception that "signals" the Python
exception from passing
through the C parts.
How does the library handle callbacks? An event loop in a separate thread? Do
you have to explicitly call some blocking function to run the event loop?
If it's a C lib likely the callbacks are just function pointers. Being called
inside a C object I'd say you assumption is correct: no C++ exceptions to be
raised inside callbacks (the lib is gcc-compiled, it has no knowledge of
exceptions).
If you could recompile with g++ the exception would raise from the event loop,
unless catched while calling the callback function pointer.
Sidenote: how does the C++ exception mechanism work under the hood? What
happens if it's called inside a C compiled function?
--
Giuseppe Corbelli
WASP Software Engineer, Copan Italia S.p.A
Phone: +390303666318 Fax: +390302659932
E-mail: [email protected]
_______________________________________________
Cplusplus-sig mailing list
[email protected]
http://mail.python.org/mailman/listinfo/cplusplus-sig