[Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash
- Next message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #2482: msvc-9.0 unreferenced formal parameter warning when using boost::breadth_first_visit"
- Previous message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #6935: Noncopyable gives compiler warning when used in DLL interface"
- Next in thread: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
#8290: Python GIL not acquired before freeing shared_ptr, causes crash
--------------------------------+-------------------------------------------
Reporter: team@⦠| Owner: rwgk
Type: Bugs | Status: new
Milestone: To Be Determined | Component: Python
Version: Boost 1.52.0 | Severity: Problem
Keywords: |
--------------------------------+-------------------------------------------
We're successfully using boost::python with Python on multiple threads
that lock and release the GIL as appropriate, and correctly set the Python
thread state, etc.
One thing we don't have control over, however, is the freeing of
shared_ptr objects which were created by boost::python. This may happen
on a different thread than the previous Python execution and/or without
the GIL being locked. To fix this, the following patch is required:
{{{
--- builtin_converters.cpp 2011-06-07 06:15:33.000000000 +0200
+++ builtin_converters.cpp.fixed 2013-03-13 12:57:29.346638173
+0100
@@ -32,7 +32,9 @@
void shared_ptr_deleter::operator()(void const*)
{
+ PyGILState_STATE gil = PyGILState_Ensure();
owner.reset();
+ PyGILState_Release(gil);
}
namespace
}}}
This fix can be applied externally to boost::python, but requires a few
header files that re-implement shared_ptr_to_python.hpp and
shared_ptr_from_python.hpp.
--
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8290>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.
- Next message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #2482: msvc-9.0 unreferenced formal parameter warning when using boost::breadth_first_visit"
- Previous message: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #6935: Noncopyable gives compiler warning when used in DLL interface"
- Next in thread: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
- Reply: Boost C++ Libraries: "Re: [Boost-bugs] [Boost C++ Libraries] #8290: Python GIL not acquired before freeing shared_ptr, causes crash"
This archive was generated by hypermail 2.1.7
: 2017-02-16 18:50:12 UTC