Subject: Re: [boost] enable_shared_from_this2
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2010-03-09 11:28:30
-----BEGIN PGP SIGNED MESSAGE-----
On Sunday 07 March 2010, Daniel F. wrote:
> I would also like to express my interest in a solution to the
> enable_shared_from_this/python problem. In my opinion providing an
> adequate solution would really benefit boost::python and I'm glad to see
> work is being done. I've checked out the latest code from svn and played
> around with it. I had to modify enable_shared_from_raw.hpp slightly in
> order to get it to compile (mainly insert esft2_deleter_wrapper from the
> old enable_shared_from_this2.hpp).
What errors did you see? Can you provide a test program which shows the
errors? The trunk works fine for me. esft2_deleter_wrapper is defined in
shared_ptr.hpp right above get_deleter.
> The results look good: the RuntimeError is gone, the objects are being
> destroyed. Unfortunately, I only know little about the inner workings
> smart pointers and even less about boost::python, so the before
> mentioned code should be regarded with caution. So far, I've discovered
> one case where this breaks, i.e. the following python code "obj2 =
> obj2.shared()" causes the assertion in the destructor of
> enable_shared_from_raw to fail. I'll assume that this is work in
> progress (or really difficult to solve).
I don't know anything about Boost.Python, but the assertion will fail if you
create a shared_ptr with shared_from_raw() and then the object is destroyed
before ever being given to an external shared_ptr. It's fine if the external
shared_ptr has a null deleter, but you have to construct such a shared_ptr
explicitly if that's what you want.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
-----END PGP SIGNATURE-----
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk