[Boost-bugs] [Boost C++ Libraries] #5226: weak_ptr in program segfaults after expiring from shared_ptr which was destructed by unloading shared library

Subject: [Boost-bugs] [Boost C++ Libraries] #5226: weak_ptr in program segfaults after expiring from shared_ptr which was destructed by unloading shared library
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-02-24 14:17:24


#5226: weak_ptr in program segfaults after expiring from shared_ptr which was
destructed by unloading shared library
----------------------------------------------------+-----------------------
 Reporter: Peter Schüller <schueller.p@…> | Owner: pdimov
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: smart_ptr
  Version: Boost Release Branch | Severity: Problem
 Keywords: |
----------------------------------------------------+-----------------------
 I have shared libraries which return shared_ptr<Foo> to my main program.

 The main program creates weak_ptr<Foo> from these shared pointers.

 Then the shared_ptr<Foo> objects are destructed (explicitly) and the
 shared library is unloaded.

 After that, expired() calls to the weak_ptr<Foo> return true, destructing
 the weak_ptr<Foo> segfaults.

 I have the suspicion that this is because weak_ptr uses a part of
 shared_ptr (this shared_count) that is supposed to survive the shared_ptr
 destruction.
 However, unloading the library invalidates the memory region where the
 code of that shared_count is located, so destructing the shared_weak_count
 fails?

 Creating a minimal example is on my TODO list, but perhaps you can already
 tell me whether this is expected, and whether a fix is even possible
 without a major change to the weak/shared ptr architecture.

 Thanks!

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