Opened 11 years ago

Last modified 11 years ago

#5640 new Bugs

serialization vector backward compatibility problem

Reported by: jfaust@… 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 Robert Ramey, 11 years ago

Owner: changed from Robert Ramey to Matthias Troyer

mattias - maybe you want to take a look at this

Robert

comment:2 by Matthias Troyer, 11 years ago

Resolution: fixed
Status: newclosed

(In [76292]) Attempting to fix #5640

comment:3 by Matthias Troyer, 11 years ago

jfaust, can you try whether the trunk after [76292] works for you?

comment:4 by Robert Ramey, 11 years ago

Resolution: fixed
Status: closedreopened

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 Robert Ramey, 11 years ago

Owner: changed from Matthias Troyer to Robert Ramey
Status: reopenednew
Note: See TracTickets for help on using tickets.