Boost logo

Boost :

Subject: [boost] 1.46 problems
From: Nikolay Mladenov (nikolay.mladenov_at_[hidden])
Date: 2011-03-02 19:31:44


I am resending this since I accidentally sent an unfinished email.

I recently upgraded from 1.43 to 1.46 and this broke our serialization.
We could not read archives saved with 1.43.
I the investigation I noticed the following issues.

1. in basic_binary_iarchive tracking_type is loaded as integer type or
bool,
    but in basic_binary_oarchive it is stored as primitive type
tracking_type.
    This breaks custom binary archives that have overloads for integer types
and bool.

this problem probably applies to other internal serialization types
(collection_size_type, version_type, etc), but I have not investigated this.

2. We use custom binary archives which have overloads for integer types
(loosely) like that:
class custom_binary_iarchive
: boost::archive::binary_iarchive_impl<custom_binary_iarchive>
{
public:
  void load(integral_type &t){...}
  void load(non_integral_type &t){...}
};

When loading std::vector from archive stored with 1.43 the following
execution paths occur:

std::vector <T> v;
custom_binary_iarchive ar(..);

ar >> v;
....
//goes in load_collection(Archive& ar, Container &s)
collection_size_type count;
ar>>BOOST_SERIALIZATION_NVP(count);
....
//and finally reaches
custom_binary_iarchive::load(non_integral_type &t);

if instead I use polymorphic archive based on the custom_binary_iarchive I
get:

std::vector <T> v;
polymorphic_iarchive_route<custom_binary_iarchive> ar(..);

ar >> v;
....
//in load_collection(Archive& ar, Container &s)
collection_size_type count;
ar>>BOOST_SERIALIZATION_NVP(count);
......
//goes into
polymorphic_iarchive_impl::load_override(nvp<collection_size_type> &t)
.....
//goes into
polymorphic_iarchive_route::load(boost::ulong_long_t &t) //since
collection_size_type has conversion to unsigned long long
...
//and finally reaches
custom_binary_iarchive::load(integral_type &t)

The bottom line is that collection_size_type deserializes differently with
polymorphic and regular archives.

I am now trying to fix the problems by introducing overloads for all the
serialization library's internal types,
but it seems to me that some of those problems are actually bugs.

Please advise on the best way to tackle this issues.

Another question I have, and excuse me if this has been discussed (but I
could not find it), is
when should a custom archive overload save/load and when
save_override/load_override?

Thanks in advance,

Nikolay Mladenov
Sitius Automation Inc


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk