Boost logo

Boost Users :

Subject: Re: [Boost-users] [serialization] Reading back old archives
From: David Raulo (david.raulo_at_[hidden])
Date: 2010-07-12 15:16:42


Hi,

Sorry this took so long, I was hit by another, unrelated bug while compiling my code with boost 1.43 (BTW that bug is already tracked in ticket #4351 and concerns mpl, but I suspect many users of your library are at risk since it helps trigger that bug).

Le 12 juil. 2010 à 01:16, Robert Ramey a écrit :

>
> David Raulo wrote:
>>
>> I saw that someone else opened ticket 3990 for the same problem.
>> Here you suggested using the function get_library_version() in the
>> following way:
>> [...]
>
> I've addressed this in the trunk and merged to release. I took special
> care to address situations such as your's. BUT... , I
> really haven't a good way to test this. So I would be greatful
> if you could download the lastest release version and verify that
> this works as I believe it should. If not, we should be able to
> fix it.

Unfortunately it does not work. The serialization library throws an exception before reaching my serialize() method. This happens at the
following XML line:
        <MyClass class_id="11" tracking_level="1" version="20090123" object_id="_11">

Here is the relevant part of the backtrace:

#8 0x001df891 in boost::serialization::throw_exception<boost::archive::archive_exception> (e=@0xbfffe2d0) at throw_exception.hpp:36
#9 0x001a3cee in boost::archive::detail::iserializer<my_xml_iarchive, MyClass>::load_object_data (this=0xbea698, ar=@0xbffff284, x=0x2a19770, file_version=36107) at iserializer.hpp:173

Here you can see that the original version 20090123 got truncated to 36107 == 20090123 & 65535. This in itself might be a bug, I'm not sure.

Then an exception is thrown because 36107 > version(). My class version is currently declared as 255, the maximum number allowed, which may need some explanations. Before boost 1.42 it was 20090123. Then with boost 1.42, I had to change the version number to 65535, because anything smaller will prevent my program from reading back some old archives, and anything bigger will cause it to write invalid new archives. Now with boost 1.43 I have the additional constraint that anything bigger than 255 will fail at compile time.

The only solution I see is to use the same integer width when reading the file_version than what is used for version(), so that both of them get truncated the same way when reading "big" version numbers from old archives. Of course this will have the side effect that I will not be be able to access the actual version number in my code.

What do you think?

Thanks for your help,
David.



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