Subject: [Boost-bugs] [Boost C++ Libraries] #10337: weak_ptr & shared_ptr causes double "delete" -> crash
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-08-10 15:57:00
#10337: weak_ptr & shared_ptr causes double "delete" -> crash
------------------------------+-----------------------
Reporter: thesaint1987@⦠| Owner: pdimov
Type: Bugs | Status: new
Milestone: To Be Determined | Component: smart_ptr
Version: Boost 1.53.0 | Severity: Problem
Keywords: |
------------------------------+-----------------------
I am not sure why this happens (VS2005 - VS2013) and specifically on
windows (code compiles and runs fine on linux)...
The following is the boost code that is responsible:
void sp_counted_impl_p<T>::release() // nothrow
{
if( BOOST_INTERLOCKED_DECREMENT( &use_count_ ) == 0 )
{
dispose();
weak_release();
}
}
void sp_counted_impl_p<T>::weak_release() // nothrow
{
if( BOOST_INTERLOCKED_DECREMENT( &weak_count_ ) == 0 )
{
destroy();
}
}
Look what MUST happen, when "use_count = 1" and "weak_count = 1".. It
causes a double release which crashes the application. That was a real
pain in the ass to track down and unfortunately I have nothing to
specifically trigger this issue either. Just look at the code and it
should be obvious that this is a race condition.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10337> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC