Re: [Boost-bugs] [Boost C++ Libraries] #4415: Posible "Segmentation Fault" in shared_ptr destructor

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4415: Posible "Segmentation Fault" in shared_ptr destructor
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-07-09 09:31:39


#4415: Posible "Segmentation Fault" in shared_ptr destructor
------------------------------------------------------+---------------------
  Reporter: Takenori Sato <takenori.sato@…> | Owner: pdimov
      Type: Bugs | Status: new
 Milestone: Boost 1.44.0 | Component: smart_ptr
   Version: Boost 1.44.0 | Severity: Problem
Resolution: | Keywords:
------------------------------------------------------+---------------------

Comment (by Takenori Sato <takenori.sato@…>):

 Here's a trivial crush test with singly linked list.

 I agree the logic looks correct. But it crushes.

 In my test, the same logic actually works, and runs fine on the same test.

 {{{

                 if(counter->decrement() == 0){
                         delete counter;
                         delete pointee_;
                 }
 }}}


 With the following two implementations.


 {{{
         unsigned int decrement(){
                 return i.fetch_sub( 1, std::memory_order_relaxed );
         }

         unsigned int decrement(){
                 assert(pthread_mutex_lock(&mutex) == 0);
                 i++;
                 assert(pthread_mutex_unlock(&mutex) == 0);
                 return i;
         }
 }}}


 I'm not familier with assembly, but is it really atomic?


 {{{
     __asm__ __volatile__
     (
         "lock\n\t"
         "xadd %1, %0":
         "=m"( *pw ), "=r"( r ): // outputs (%0, %1)
         "m"( *pw ), "1"( dv ): // inputs (%2, %3 == %1)
         "memory", "cc" // clobbers
     );
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4415#comment:2>
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:03 UTC