0

What reasons could there be for boost-python not to be able to catch an exception thrown in an extension module written using it's help and translate it to python? Instead, the interpreter crashes with terminate called after throwing an instance of '<some_excpetion_class>'.

My extension module is using some functions from CGAL, to which it links dynamically, and which throws the exception. It also links dynamically to the boost_python shared library. I'm on linux. It's written in '-std=c++11' and I prefer to compile with clang.

My first thought was that this is a problem of throwing exceptions accross shared library boundaries. However, I did everything I could imagine to circumvent the problem, suggesting it has nothing to do with this:

  • The exception translation properly works for other exceptions thrown from my code
  • I tried compiling both with clang 3.4 and gcc 4.8.2
  • The code throwing is a header from CGAL, in a failing assert macro which calls info a fail function in the CGAL shared library. However, re-defining that macro such that it raises from within the extension module did not help, independent if the exception class was from CGAL or a std::exception or a boost::exception child class.

Any thoughts?

burnpanck
  • 1,955
  • 1
  • 12
  • 36

1 Answers1

0

Found the reason, which had nothing to do neither with boost-python nor shared libraries:

The CGAL code is throwing from a destructor, which leads to program termination. See also: throwing exceptions out of a destructor.

Community
  • 1
  • 1
burnpanck
  • 1,955
  • 1
  • 12
  • 36