Boost logo

Boost Users :

From: Gancho Manev (gmanev_at_[hidden])
Date: 2008-06-06 06:08:19


Hi,

The following code does not throw archive_exception always:

std::stringstream ss;
boost::archive::text_iarchive ia(ss);

The archive_exception is thrown always on VC++2005/Windows while on
GCC3.2.2/Redhat8 and GCC3.4.6/CentOS a std::length_error:
basic_string::resize is thrown sometimes.

That means the constructor tries to resize some string with value >
basic_string.max_size(). The GCC defines the max_size() to be only about
a quarter of the max length the allocator can get. That explains why
that exception happens to be raised on GCC.

A search of the source code lead me to the overloaded methods 'load' of
text_iarchive_impl<Archive>. They look suspicious because do not check
the input stream state before using the string size just loaded. The
local variable is not initialized nor loaded, so it contains some
arbitrary value! In the method load(std::string&) that might cause
std::length_error while in load(char *s) - even program crash.

The code in the next Boost versions does not seem to be changed.

Has anyone encountered such behavior? I've not found that bug reported.

Thanks in advance,
Gancho


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