I think the problem will be resolved by defining
 
BOOST_SERIALIZATION_VECTOR_VERSION 4

rather than 3 as it is above.

Unless someone tells me I'm missing something, I'm checking in this change to the trunk.

Robert Ramey

 

"David Graf" <david.graf@28msec.com> wrote in message news:D84C651B-510D-4D80-8224-5C09542F74DE@28msec.com...
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@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users





_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users



_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users


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@lists.boost.org
>>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>>>
>>>
>>
>>
>>
>>> _______________________________________________
>>> Boost-users mailing list
>>> Boost-users@lists.boost.org
>>> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users@lists.boost.org
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users