Boost logo

Boost Users :

From: Julien Pervillé (julien.perville_at_[hidden])
Date: 2006-06-05 14:20:59


Hello boost-users!

I would like to report a minor (but annoying) bug in the
boost::serialization library which I am using extensively in my
project.

The problem: trying to load serialized data from a known invalid
archive does not throw a boost::archive::archive_exception but instead
a normal std::exception is caught.
Note: the bug seems to only affect GNU/Linux systems.

The annoyance is minor since some kind of exception is caught anyway so
that corrective action can be taken. At some point in my application's
test suite, I test the robustness of my persistence code by feeding my
Load() method a malformed buffer. If I run the test suite normally I
get the expected result that is an exception happened and the program
refused to corrupt its internal data structure. However, when running
under Valgrind looking for leakage, I get spammed by "Conditional jump
or move depends on uninitialised value(s)" messages.

It appears that boost::serialization does not notice that my source
stream is a malformed archive and recklessly tries to read the
serialized data. As I can see in the many "load" methods from
"boost/archive/impl/text_iarchive_impl.ipp" (the last method invoked
before the exception occurs), the archive loader attempted to read a
"size" from the malformed data and then attempted to resize its buffer
to this (undefined) size, ensuing mayhem. Aren't the archive loaders
supposed to check that a stream is a valid archive before
deserializing? I would imagine that the
boost::archive::archive_exception::invalid_archive error code is made
for that purpose.

Here are instructions on how to trigger the bug: a very simple
boost::serialization example and the valgrind trace (compiled with -g).
Here is a sample execution of the program:

jp_at_linux ~/boost $ ./malformed-contents
caught exception : basic_string::resize

The compiler used was g++-4.1 on GNU/Linux (amd athlon, gentoo
distribution, glibc 2.3.6). I reproduced the issue on another GNU/Linux
box with an AMD 64 and g++ 3.4 and obtained the same issue.

However, running the test on my ibook (Apple OSX) returned me the
expected behavior :

ibook:~/boost jp$ ./malformed-contents
caught boost exception : invalid signature

The issue seems to only affect some GNU/Linux systems.

Thank you for the help,
Sincerely,

Julien Pervillé
Intern, Global Core, Amadeus IT Group.





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