Opened 11 years ago
Last modified 11 years ago
#5640 new Bugs
serialization vector backward compatibility problem
| Reported by: | Owned by: | Robert Ramey | |
|---|---|---|---|
| Milestone: | To Be Determined | Component: | serialization |
| Version: | Boost 1.46.1 | Severity: | Regression |
| Keywords: | Cc: |
Description
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.
Change History (5)
comment:1 by , 11 years ago
| Owner: | changed from to |
|---|
comment:2 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
comment:4 by , 11 years ago
| Resolution: | fixed |
|---|---|
| Status: | closed → reopened |
I don't think this has anything to do with MPI. I also don't think it's been solved. I'll take over here. If I can figure out how to reassign this ticket to me
Robert Ramey
comment:5 by , 11 years ago
| Owner: | changed from to |
|---|---|
| Status: | reopened → new |

mattias - maybe you want to take a look at this
Robert