id summary reporter owner description type status milestone component version severity resolution keywords cc 2584 boost::enable_shared_from_this + boost.python library Nicolas Lelong Peter Dimov "A problem that was raised, on february, on c++-sig mailing list about a problem happening when wrapping classes derived from 'enable_shared_from_this' using boost.python library. The problem is briefly described in this post - including a patch to boost/shared_ptr.hpp that would allow to work around the problem. http://mail.python.org/pipermail/cplusplus-sig/2008-February/012973.html To make it short, boost.python creates shared_ptr objects, holding the wrapped c++ objects, with a custom deleter managing the python object reference count. This leads to something like that : #include namespace {[[BR]] class A : public boost::enable_shared_from_this[[BR]] {[[BR]] public:[[BR]] ~A() {};[[BR]] };[[BR]] void my_deleter(void*)[[BR]] {[[BR]] }[[BR]] };[[BR]] BOOST_AUTO_TEST_CASE( test_enable_shared_from_this )[[BR]] {[[BR]] boost::shared_ptr a( new A );[[BR]] {[[BR]] boost::shared_ptr ater = [[BR]] boost::shared_ptr( a.get(), my_deleter );[[BR]] // OP patch proposal:[[BR]] // boost::shared_ptr ater = [[BR]] // boost::shared_ptr( a.get(), my_deleter[[BR]] // , boost::dont_enable_shared_from_this() );[[BR]] BOOST_CHECK( a == ater );[[BR]] }[[BR]] boost::shared_ptr abug = a->shared_from_this(); // this throws bad_weak_ptr[[BR]] } " Bugs closed Boost 1.39.0 smart_ptr Boost 1.37.0 Problem fixed enable_shared_from_this