[Boost-bugs] [Boost C++ Libraries] #3837: thread_specific_ptr returns incorrect values if another one was constructed at the same address earlier

Subject: [Boost-bugs] [Boost C++ Libraries] #3837: thread_specific_ptr returns incorrect values if another one was constructed at the same address earlier
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-01-12 19:22:02


#3837: thread_specific_ptr returns incorrect values if another one was constructed
at the same address earlier
--------------------------+-------------------------------------------------
 Reporter: anonymous | Owner: anthonyw
     Type: Bugs | Status: new
Milestone: Boost 1.42.0 | Component: thread
  Version: Boost 1.41.0 | Severity: Problem
 Keywords: |
--------------------------+-------------------------------------------------
 optional< thread_specific_ptr<int> > optr;

 void other_thread(){
 Â  optr=none;
 Â  optr=in_place();
 }

 int main(){
 Â  optr=in_place();
 Â  optr->reset(new int);

 Â  thread(bind(&other_thread));
 Â  this_thread::sleep(posix_time::seconds(5));

 Â  assert(optr->get() == 0); //fails!
 }

 the assertion should not fail.

 this can also be triggered by dynamic allocation.
 the address of thread_specific_ptr is treated as a key that is unique
 until the end of the thread in Boost.Thread, which is an incorrect
 assumption.
 a unique key obtained under a mutex on construction of thread_specific_ptr
 could be used instead.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3837>
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:02 UTC