Boost logo

Boost Users :

Subject: Re: [Boost-users] Serialization Archive IncompatibilitybetweenBoostVersions
From: David Graf (david.graf_at_[hidden])
Date: 2009-05-19 08:05:49


Hello Robert

After adding nvp wrappers around all serialize commands, I am able to
produce the xml archives (attached inclusive diff).

The archive produced using boost 1.37 contains the additional element
'<item_version>0</item_version>. This additional element seems to be
inserted by the std::vector serialization code. I compared the load
function in vector.hpp from version 1.35 and 1.37 (see code below).
The version 1.37 tries to load the variable item_version that is not
saved by version 1.35.

Is the condition around the additional code
(BOOST_SERIALIZATION_VECTOR_VERSION < ar.get_library_version())
executed wrongly?

David

version 1.35:
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);
     if (!t.empty())
       ar >> make_array(detail::get_data(t),t.size());
   }

version 1.37:
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());
   }

On May 18, 2009, at 6:52 PM, Robert Ramey wrote:

> This looks useful.
>
> May we presume that you're trying to read this with boost 1.37 and the
> exception is thrown?
>
> Note that the the 1.35 version has archive library version #4 while
> 1.37 has
> archive library version #5 in the top row. The archive library
> version is
> changed every time we make a change which might mean that older
> archive have
> to be handled differently. A example where this has happened is
> where we
> change the type of the integer which indicates how may items there
> are in a
> collection.
>
> In this case, 1.37 (library version # 5) is expecting data which 1.35
> (library version #4) didn't put there. That is, 1.37 is missing some
> code
> which looks like:
>
> if(library_version >4)
> ar >> i
> ...
>
> Of course the rub is to figure out where that is. The key line
> differs in
> that:
>
> 1.35 1 12 ...
> 1.37 1 0 12 ... // extr 0
> With your test case I would do the following:
>
> Generate the same two files with the xml_archive. This should
> reveal what
> the extra "0" corresponds to.
> With the debugger, trap the program where the exception is thrown.
> This
> might reveal the part of code which is throwing this extra "0".
> This is
> where the mistake might lie.
>
> Robert Ramey
>
>
>
> David Graf wrote:
>>> Hello Robert
>>>
>>> Attached, please find two text archive outputs. The first is
>>> generated using boost version 1.35. The second is generated using
>>> boost version
>>> 1.37. Additionally, I attached the diff between these archives.
>>>
>>> In this diff, you can safely ignore the second and the last
>>> difference. Those are due to random generated data. We assume that
>>> the exception (see attached stacktrace.txt) is caused by the third
>>> difference.
>>>
>>> Do you have any idea why this exception is thrown?
>>>
>>> David
>>>
>>>
>>>
>>>
>>
>>
>>
>>>
>>>
>>>
>>>
>>> On Apr 9, 2009, at 6:38 PM, Robert Ramey wrote:
>>>
>>>> This version is declared at the beginning of a serialized archive.
>>>> E.g.:
>>>>
>>>>
>>>> The following beginning of a text archive is serialized with boost
>>>> 1.37:
>>>> 22 serialization::archive 5 0 35 ...
>>>>
>>>>
>>>> Serialized with boost 1.35 it looks like this:
>>>> 22 serialization::archive 4 0 35 ...
>>>>
>>>>
>>>> Otherwise, the archives are in my case completely identical.
>>>>
>>>>
>>>> Somehow, if this version number does not match to the serialized or
>>>> archive
>>>> version of the used boost library, boost throws an exception.
>>>>
>>>> **** where does this exception get thrown?
>>>>
>>>>
>>>> Robert Ramey
>>>>
>>>>
>>>>
>>>> _______________________________________________
>>>> Boost-users mailing list
>>>> Boost-users_at_[hidden]
>>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>>>
>>
>>
>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users_at_[hidden]
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users









Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net