[Boost-bugs] [Boost C++ Libraries] #5876: Serialization - tracking of non-versioned classes

Subject: [Boost-bugs] [Boost C++ Libraries] #5876: Serialization - tracking of non-versioned classes
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-09-08 09:42:18


#5876: Serialization - tracking of non-versioned classes
------------------------------------+---------------------------------------
 Reporter: ybungalobill@… | Owner: ramey
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
  Version: Boost 1.47.0 | Severity: Showstopper
 Keywords: |
------------------------------------+---------------------------------------
 I quote a case from my workplace. The issue came up for std::vector<int>,
 but I use a simple struct X to reproduce the problem. See the attached
 file for detailed instructions.

 Opened by Yakov Galka 9/8/2011 (Today) 8:31 AM Edit

 The following code:

 {{{
     struct X { ... };

     X x2;
     BoostLoad("SerializationBug.dat", x2);

 #if FLAG
     volatile int x = 0;
     if(x)
     {
         X *x3;
         BoostLoad("this code is never executed", x3);
     }
 #endif
 }}}

 Produces different results depending on whether FLAG == 0 or 1, although
 it's clear that it must not change it's behavior.

 After some research it happens that the handling of tracking level is
 broken in boost since at least boost 1.46.1.

 Assigned to Yakov Galka by Yakov Galka 9/8/2011 (Today) 8:31 AM
 Notified ######.

 Edited by Yakov Galka 9/8/2011 (Today) 8:53 AM [Revised 11:44 AM] Edit

 It happens for objects with implementation level of object_serializable.
 That is:

 {{{
 BOOST_CLASS_IMPLEMENTATION(X, boost::serialization::object_serializable)
 }}}

 For greater implementation level, the tracking level is read from the
 archive. However it still must affect the saving of objects to any
 archives (binary, xml, text).

 If it's not clear enough, the above code reads/writes the the file
 correctly when FLAG == 0, but tries to load x2 as-if it's tracked when
 FLAG == 1.

 Edited by Yakov Galka 9/8/2011 (Today) 10:38 AM Edit
 I've successfully reproduced this same bug in boost 1.33.1, although there
 it's silent (no crash, just wrong data is read). Boost serialization is
 broken really hard on the low-level:

 basic_iserializer::tracking() decides whether the class should be tracked
 or not based on m_bpis value. However it can't decide this based on the
 information it has, since it's shared among objects serialized trough a
 pointer and not through a pointer.

 Possible Fix: make basic_iserializer::tracking return the tracking level
 instead of a boolean value and let the caller decide what this tracking
 level means. It's a lot of work, and it may break computability with
 archives serialized incorrectly in 1.33.1, which happens to be possible.
 We are screwed anyway.

 Edited by Yakov Galka 9/8/2011 (Today) 11:44 AM

 Revised Yakov Galka's 8:53 AM entry from 9/8/2011

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