Re: [Boost-bugs] [Boost C++ Libraries] #4660: Error read binary archive, created by old boost version

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #4660: Error read binary archive, created by old boost version
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-22 19:54:40


#4660: Error read binary archive, created by old boost version
---------------------------------------+------------------------------------
  Reporter: serge-voropaev@… | Owner: ramey
      Type: Bugs | Status: reopened
 Milestone: Boost 1.45.0 | Component: serialization
   Version: Boost 1.45.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------+------------------------------------

Comment (by markus.henschel@…):

 I made a last effort to get this stuff fixed and did a lot of research. I
 have tested library versions from 1.34.1 to 1.46.1 with regards to how
 they store different types in binary archives. Because the main problem is
 that sizes for some types differ between library versions I tested how
 these types were serialized in different versions of the library:
 -version_type[[BR]]
 -class_id_type[[BR]]
 -class_id_reference_type[[BR]]
 -object_id_type[[BR]]
 -object_reference_type[[BR]]
 -tracking_type[[BR]]
 -collection_size_type[[BR]]

 These files that are relevant:[[BR]]
 1. boost/archive/binary_oarchive.hpp[[BR]]
 This file contains overrides for storing the mentioned types that changed
 in size.

 2. boost/archive/basic_archive.hpp[[BR]]
 This file defined the the types mentioned above.[[BR]]

 3. boost/archive/binary_iarchive.hpp[[BR]]
 This file contains several load_override member functions that handle
 backwards compatibility to older archive versions.

 With different versions of the library the save overrides changed as well
 as the definitions of the types themselves. But for every version there is
 one definite type that has it's memory written to the output stream
 buffer. So I created an excel table that lists this information and
 attached it.

 The essence of this research is the following:
 a) The source of the problem started in 1.44. The documentation and the
 maintainers comments indicate that 1.42 changed the size of several types.
 This is true but it wasn't problematic for binary archives because they
 did explicitly override the serialization of these types. For instance
 class_id_type changed from int to int_least16_t but this didn't matter for
 the serialization of this type because the binary output archive stored it
 as a 16 bit type anyway. (To be precise the type used in save_override
 also changed but only from uint_least16_t to int_least16_t and this
 shouldn't usually cause any trouble unless a lot of classes are being
 used.)

 b) 1.44.0 removed the custom save_override functions for most types but
 the only type that really got a different binary representation is
 version_type. It changed from char to uint_least32_t. At the same time a
 load_override function was added but it used the wrong type for older
 archives. Instead of unsigned char is used unsigned int. Because 1.44.0
 didn't increase the archive number it cannot be distinguished from
 archives of 1.42.0 and 1.43.0. All have version 7.

 c) Later changes fixed some things but introduced new bugs. It seems like
 the code tries to read all types like they are defined in
 basic_archive.hpp in the respective version of the library. The results
 are hit or miss. The problem is that the fixes seem to ignore the fact
 that these types had save_override functions in prior library versions
 that did alter the type actually stored in the data stream. So the current
 situation is much worse than it has to be.


 d) The only "unfixable" problem is that 1.42, 1.43 and 1.44 have the same
 version number. Either 1.42+1.43 or 1.44 cannot be loaded.


 I contacted the maintainer Robert Ramey via the boost developer mailing
 list and he agreed to at least take a look at the issue. I took a long
 time to extract all this information. I will provide a proper fix next
 week. Hopefully it will make it into boost so I can work with an unpatched
 boost version again.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4660#comment:51>
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:12 UTC