Andrey Semashev | 11 Oct 11:42

[shared_ptr] Ticket 2126 status?

Hi,

Is the ticket 2126:

http://svn.boost.org/trac/boost/ticket/2126

actually fixed in trunk? The ticket is still open, but my code that uses
enable_shared_from_this and make_shared runs fine on trunk. However, the
 issue is still present in the release branch. If the problem is
actually fixed, and the fixture doesn't break anything else I'd like to
ask to merge the change to the release branch. Thanks.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Peter Dimov | 11 Oct 14:31

Re: [shared_ptr] Ticket 2126 status?

Andrey Semashev:

> Is the ticket 2126:
>
> http://svn.boost.org/trac/boost/ticket/2126
>
> actually fixed in trunk? The ticket is still open, but my code that uses
> enable_shared_from_this and make_shared runs fine on trunk.

Interesting. No, I don't believe that trunk is OK. The constructor support 
just masks the problem. Try for example the following test:

#include <boost/shared_ptr.hpp>
#include <boost/enable_shared_from_this.hpp>
#include <boost/make_shared.hpp>
#include <boost/detail/lightweight_test.hpp>

struct X: boost::enable_shared_from_this<X>
{
    bool destroyed_;

    X(): destroyed_( false ) {}
    ~X() { destroyed_ = true; }
};

int main()
{
    boost::shared_ptr<X> px = boost::make_shared<X>();
    boost::shared_ptr<X> px2 = px->shared_from_this();

(Continue reading)

Andrey Semashev | 11 Oct 15:40

Re: [shared_ptr] Ticket 2126 status?

Peter Dimov wrote:
> Andrey Semashev:
> 
>> Is the ticket 2126:
>>
>> http://svn.boost.org/trac/boost/ticket/2126
>>
>> actually fixed in trunk? The ticket is still open, but my code that uses
>> enable_shared_from_this and make_shared runs fine on trunk.
> 
> Interesting. No, I don't believe that trunk is OK. The constructor
> support just masks the problem. Try for example the following test:

Right, this one fails, indeed. I guess, I've been lucky so far since I
didn't encounter any problems. Thanks for pointing this out.
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Andrey Semashev | 11 Oct 17:44

Re: [shared_ptr] Ticket 2126 status?

Peter Dimov wrote:
> Andrey Semashev:
> 
>> Is the ticket 2126:
>>
>> http://svn.boost.org/trac/boost/ticket/2126
>>
>> actually fixed in trunk? The ticket is still open, but my code that uses
>> enable_shared_from_this and make_shared runs fine on trunk.
> 
> Interesting. No, I don't believe that trunk is OK. The constructor
> support just masks the problem. Try for example the following test:

I tried to dig the code here and there. It seems like calling
sp_accept_owner for the constructed object would settle the problem. I
modified make_shared.hpp accordingly and tried your test on Linux (GCC
4.3), and it passed without errors. I also tried the
make_shared_test.cpp test and it also passed.

Please, find the patch attached. Is it valid?

Index: make_shared.hpp
===================================================================
--- make_shared.hpp	(revision 48913)
+++ make_shared.hpp	(working copy)
@@ -98,12 +98,14 @@

     detail::sp_ms_deleter< T > * pd = boost::get_deleter< detail::sp_ms_deleter< T > >( pt );
(Continue reading)


Gmane