boostorg / boostorg/python

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

Đang mở
#152 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
C++
Star
537
Fork
223
Merge trung bình
11 giờ 22 phút
Pull request đã merge (30 ngày)
2

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.