Subject: [Boost-bugs] [Boost C++ Libraries] #5640: serialization vector backward compatibility problem
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-24 21:17:06
#5640: serialization vector backward compatibility problem
---------------------------------+------------------------------------------
Reporter: jfaust@⦠| Owner: ramey
Type: Bugs | Status: new
Milestone: To Be Determined | Component: serialization
Version: Boost 1.46.1 | Severity: Regression
Keywords: |
---------------------------------+------------------------------------------
We've recently upgraded from 1.40.0 to 1.46.1 and uncovered the following
problem with vector serialization.
In 1.40.0, the code to load a vector is:
{{{
#ifndef BOOST_SERIALIZATION_VECTOR_VERSION
#define BOOST_SERIALIZATION_VECTOR_VERSION 4
#endif
...
template<class Archive, class U, class Allocator>
inline void load(
Archive & ar,
std::vector<U, Allocator> &t,
const unsigned int /* file_version */,
mpl::true_
){
collection_size_type count(t.size());
ar >> BOOST_SERIALIZATION_NVP(count);
t.resize(count);
unsigned int item_version=0;
if(BOOST_SERIALIZATION_VECTOR_VERSION < ar.get_library_version())
ar >> BOOST_SERIALIZATION_NVP(item_version);
if (!t.empty())
ar >> make_array(detail::get_data(t),t.size());
}
}}}
In 1.46.1, the same method is
{{{
#ifndef BOOST_SERIALIZATION_VECTOR_VERSIONED
#define BOOST_SERIALIZATION_VECTOR_VERSIONED(V) (V==4 || V==5)
#endif
...
template<class Archive, class U, class Allocator>
inline void load(
Archive & ar,
std::vector<U, Allocator> &t,
const unsigned int /* file_version */,
mpl::true_
){
collection_size_type count(t.size());
ar >> BOOST_SERIALIZATION_NVP(count);
t.resize(count);
unsigned int item_version=0;
if(BOOST_SERIALIZATION_VECTOR_VERSIONED(ar.get_library_version())) {
ar >> BOOST_SERIALIZATION_NVP(item_version);
}
if (!t.empty())
ar >> make_array(detail::get_data(t),t.size());
}
}}}
Look at the difference when reading in a vector from serialization library
version 4. In 1.40.0, the logic assumes that versions greater than 4
should read in item_version. In 1.46.1, the logic assumes that versions
equal to 4 or 5 should read in item_version. So, if restoring a file
saved with version 4, 1.40.0 will not ready in item_version but 1.46.1
will.
We are working around this issue with a trick similar to the header
vector_135.hpp, but would like to see this fixed in an upcoming release.
After some research, I found this change was made with changeset 55415 for
ticket 2271.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5640> 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:06 UTC