Boost logo

Boost :

From: Jamie Allsop (ja11sop_at_[hidden])
Date: 2008-02-04 16:28:16

Jamie Allsop wrote:
> I hate to post this as it's late and I can't help thinking I'm missing
> something obvious, but here goes. I am getting an exception thrown as a

I was right to be cautious, as I was missing the obvious.

> result of executing line 52 of
> boost/trunk/boost/archive/impl/basic_binary_iarchive.ipp
> (yes I'm using trunk, but this happens with my 1.34.1 also)
> The little program shown below causes it, the output of which is,
> "std::exception: basic_string::resize"

Actually the real culprit was line 96 in

I first saw this in a program that was streaming an archive over tcp
using asio. For one reason and another I ended up producing an invalid
archive (like the one in my example). The std::string::resize()
exception threw me and sent me up the wrong path.

The reason I am replying to this is that this exception may, or may not
get thrown when you try to create an invalid archive, and of course if
it does get thrown it doesn't really help much in diagnosing the problem.

AFAICT there is no sensible way to detect an invalid archive until you
try to deserialize it. However if this exception is thrown you can be
fairly certain that your archive is invalid. I suggest then that it
might be appropriate to translate this exception into one more
meaningful to the user of the archive, something that indicated that the
archive itself is likely to be invalid.

There are many archive exceptions listed in the serialization

This is obviously not one of them. It would be a good idea to either add
this exception with a note or translate the actual exception into one
meaningful to serialization archives, something like,


Boost list run by bdawes at, gregod at, cpdaniel at, john at