Boost logo

Boost :

From: SourceForge.net (noreply_at_[hidden])
Date: 2004-07-11 22:04:51


Bugs item #989168, was opened at 2004-07-11 20:04
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=989168&group_id=7586

Category: smart_ptr
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Peter Dimov (pdimov)
Summary: intrusive_ptr may cause dungling ptr access

Initial Comment:
I think intrusive_ptr may cause dungling ptr access in
multithreaded environment.

Currently, it's constructor is:

    intrusive_ptr(T * p, bool add_ref = true)
    : p_(p) /* the object may be deleted by other
thread
                because this thread does not increment
reference counter yet. */
    {
        if(p_ != 0 && add_ref)
            intrusive_ptr_add_ref(p_); /* this may occur
dungling ptr operation. */
    }

We can avoid this problem by "addref-before-use" policy.

    intrusive_ptr(T * p, bool add_ref = true)
    {
        if(p != 0 && add_ref)
            intrusive_ptr_add_ref(p_); /* other thread
never delete the object */
        p_ = p;
    }

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=107586&aid=989168&group_id=7586

-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Boost-bugs mailing list
Boost-bugs_at_[hidden]
https://lists.sourceforge.net/lists/listinfo/boost-bugs


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk