boostorg / boostorg/python

Boost.Python should not catch C++ exception allowing std::terminate call

Ouverte
#152 3 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
C++
Étoiles
537
Forks
223
Merge moyen
11 h 22 min
PR mergées (30 j)
2

Description

All calls of C/C++ functions and methods are wrapped in Boost.Python internals by try-catch constructions. The specific code is in boost::python::handle_exception_impl() and in make_holder::apply::execute. There are good reasons to do it and they are described in the Reference. But due to handling of exceptions in Boost.Python internals core dumps are never created. Core dumps are generated only when unhandled exceptions are being thrown. handle_exception_impl() handles all stdlib exception and even all unknown exceptions (with catch(...) block ). Although it is possible to catch exceptions from C/C++ code by registering custom exception translators, it is impossible to get core dump for post-mortem analysis. The fundamental problem here is that at the moment when any exception handler is invoked (in exception translator or in custom catch(){} block ) the stack of calls is already unwinded and information about point of exception throwing is already lost. Even if the exception is just rethrown by the handler, and is not handled further, the call stack into the core dump will show the handler as a point of exception throwing, without information about original problem source.

I think that try-catch blocks in handle_exception_impl() and make_holder::apply::execute() should be removed. Alternatively, probably an option could be added to the def macros (the one nested in BOOST_PYTHON_MODULE() macros) that would control the strategy of exception handling. Anyway, current solution significantly complicates debugging of C/C++ modules and IMHO it should be fixed.

The similar problem was considered here: [ Impossible to find/debug unhandled exceptions in an std::thread](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=55917)
Finally they decided to "Remove try-block so that exceptions propagate out of the thread and terminate".

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.