Boost logo

Boost Users :

From: Robert Ramey (ramey_at_[hidden])
Date: 2007-02-02 19:30:58


Here are a couple of ideas:

a) catch the archive exceptions and display an error message which
describes what kind of exception has been thrown.

b) Set your debugger to trap when the exception is thrown
and look at the source code at that spot. This should contain
some extra info about why the library is unable to proceed.

c) Just a while guess - thrown from load binary might suggest
either the file isn't being opened binary, or the size of data
being read isn't the same as what's being saved.

d) Sometimes this can occur when the save/load serialization
is "out of sync". that is the save and load are not code
symetrically. This might occur due to a program change
without the use of versioning. It is sometimes helpful to
save/load with xml_archive just to double check. The
serialization library archives for xml actually check the
xml tags so that if something is out of sync it is detected
immediatly.

Robert Ramey

Adrian Grigore wrote:
> Hi,
>
> I'm experiencing occasional problems with boost::serialization when
> trying to write then read two simple classes, to a file. I am using
> boost 1.33.1
>
> Most of the time everything's working fine, but sometimes the
> serialized data seems to be corrupt and boost::archive throws an
> exception when I try to load it back into the program. The error
> occurs about about 1 in 10 times I try this, and seems to depend on
> the exact values of the variables being saved.
>
> Here's a call stack of the thrown application:
>
> WxNonogram.exe!_CxxThrowException(void * pExceptionObject=0x00129680,
> const _s__ThrowInfo * pThrowInfo=0x00ff4954) + 0x50 bytes C++
> WxNonogram.exe!boost::throw_exception<boost::archive::archive_exception>(const
> boost::archive::archive_exception & e={...}) + 0x40 bytes C++
>
> WxNonogram.exe!boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive,std::basic_istream<char,std::char_traits<char>
>>>>> load_binary(void * address=0x0012d05c, unsigned int count=4) +
>>>>> 0xaf bytes C++
>
> WxNonogram.exe!boost::archive::basic_binary_iprimitive<boost::archive::binary_iarchive,std::basic_istream<char,std::char_traits<char>
>>>>> load<int>(int & t=-858993460) + 0x31 bytes C++
>
> WxNonogram.exe!boost::archive::load_access::load_primitive<boost::archive::binary_iarchive,int>(boost::archive::binary_iarchive
> & ar={...}, int & t=-858993460) + 0x2d bytes C++
>
> WxNonogram.exe!boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive,int>::load_primitive::invoke(boost::archive::binary_iarchive
> & ar={...}, int & t=-858993460) + 0x2b bytes C++
>
> WxNonogram.exe!boost::archive::detail::load_non_pointer_type<boost::archive::binary_iarchive,int>::invoke(boost::archive::binary_iarchive
> & ar={...}, int & t=-858993460) + 0x2b bytes C++
>
> WxNonogram.exe!boost::archive::load<boost::archive::binary_iarchive,int>(boost::archive::binary_iarchive
> & ar={...}, int & t=-858993460) + 0x2b bytes C++
>
> WxNonogram.exe!boost::archive::basic_binary_iarchive<boost::archive::binary_iarchive>::load_override<int>(int
> & t=-858993460, int __formal=0) + 0x38 bytes C++
>
> WxNonogram.exe!boost::archive::binary_iarchive_impl<boost::archive::binary_iarchive>::load_override<int>(int
> & t=-858993460, int __formal=0) + 0x31 bytes C++
>
> WxNonogram.exe!boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator>><int>(int
> & t=-858993460) + 0x38 bytes C++
>
> WxNonogram.exe!boost::archive::detail::interface_iarchive<boost::archive::binary_iarchive>::operator&<int>(int
> & t=-858993460) + 0x39 bytes C++
>
> WxNonogram.exe!NoNo::TGameProgress::TProfileState::serialize<boost::archive::binary_iarchive>(boost::archive::binary_iarchive
> & ar={...}, const unsigned int Version=4) + 0x7a bytes C++
>
>
> Please help! I'm at a loss on how to proceed.
>
> Thanks for your time,
>
> Adrian


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