boostorg / boostorg/python

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

未关闭
#152 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C++
星标
537
派生
223
平均合并
11 小时 22 分钟
30 天内合并 PR
2

描述

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".

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。