Re: [Boost-bugs] [Boost C++ Libraries] #4842: "pure virtual method called; terminate called without an active exception" on shutdown

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4842: "pure virtual method called; terminate called without an active exception" on shutdown
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-03-19 00:14:23


#4842: "pure virtual method called; terminate called without an active exception"
on shutdown
-------------------------------+--------------------------------------------
  Reporter: eric_niebler | Owner: ramey
      Type: Bugs | Status: reopened
 Milestone: To Be Determined | Component: serialization
   Version: Boost 1.44.0 | Severity: Regression
Resolution: | Keywords: serialization singleton
-------------------------------+--------------------------------------------

Comment (by Aaron Barany <akb825@…>):

 This issue affects not only *nix shared libraries, but also Windows DLLs.
 I have attached a patch that fixes this issue. However, there are still
 situations where this can break, which I will discuss.

 The change that caused this regression was in
 void_caster::recursive_unregister(). It does a loop over the entire set of
 registered void casters to remove all related void casters to the one
 being unregistered. In boost 1.43 and prior, it used to compare the
 pointer in the iterator to this within the loop to remove itself. However,
 in the boost 1.44 release that was changed to doing a find and erase after
 the loop. Since there are void_caster objects in the map with invalid
 extended type infos, that find caused a pure virtual function call.

 I think the reason why it has invalid extended type infos in the map is
 due to how it registers the void caster shortcuts. In
 void_caster::recursive_register(), it will grab the extended type info
 from related void_casters, but those objects could reside in another
 library. Since only the current void caster being registered is marked as
 the parent, and not the other one it gets the other extended type info
 from, the other extended type info can be destructed before all the
 void_casters that use it are unregistered.

 Though my patch, which restores the previous behavior, works around the
 issue during normal program startup and shutdown, if you dynamically load
 two libraries then later unload the first one, leaving the second library
 loaded, you can potentially have invalid void casters left behind to cause
 a crash the next lookup. Unfortunately, getting this to work properly will
 be very tricky, since if you simply unregister the void caster in this
 case, the void cast itself may still be valid, you just need a different
 extended type info instance to handle the comparison. I see two potential
 paths you can take to fix this: either set up some sort of system to
 replace extended type infos being destructed with valid equivalents or
 remove the shortcuts and use recursive lookups instead.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4842#comment:21>
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