Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost serialisation: base ptr regression in 1.42
From: Robert Ramey (ramey_at_[hidden])
Date: 2010-03-27 19:15:33


Avi Bahra wrote:
> I have a serious regression in boost 1.42 serialisation.
> Now getting a unregistered class, exception, on Suse linux
> using gcc 4.2.1. This test passes on boost 1.39/1.40.
>
> There are 3 files involved to recreate the crash:
> included below:
> Main.cpp
> BaseHolder.hpp
> BaseHolder.cpp
>
> The file BaseHolder.hpp/cpp defines 3 classes
> Base
> Derived
> BaseHolder
>
> Here is what I found:
> 1/ If all the functionality is put in one file.
> i.e Main.cpp then _no_ crash
> 2/ If all 3 files are compiled together then
> _no_ crash
> 3/ However if BaseHolder is added to static library
> and linked with Main.cpp
> then we get the _crash_ ( only in 1.42 )
>
>
> Also getting a spurious warning message:
> Again this warning only appears in 1.42
>
> /var/tmp/ma0/boost/boost_1_42_0/boost/mpl/print.hpp: In instantiation
> of
> ?boost::mpl::print<boost::serialization::BOOST_SERIALIZATION_STATIC_WARNING_LINE<98>
> >?:
> /var/tmp/ma0/boost/boost_1_42_0/boost/serialization/static_warning.hpp:92:
> instantiated from ?boost::serialization::static_warning_test<false,
> 98>?
> /var/tmp/ma0/boost/boost_1_42_0/boost/archive/detail/check.hpp:98:

******
The code comment at check.hpp : 98 says:

// may be an indicator of an error usage of the
// serialization library and should be double checked.
// See documentation on object tracking. Also, see the
// "rationale" section of the documenation
// for motivation for this checking.

....
> /var/tmp/ma0/clientRoot/workspace/MyProject/SCRATCH/src/Main.cpp:16:
> instantiated from here
> /var/tmp/ma0/boost/boost_1_42_0/boost/mpl/print.hpp:55: warning:
> comparison between signed and unsigned integer expressions
> gcc.archive bin/gcc-4.2.1/debug/link-static/libnodeattr.a
> gcc.link bin/gcc-4.2.1/debug/test

change
> int main()
> {
> std::string fileName = "test.txt";
> { // If this scope is commented out, crash goes away ???
> Derived saved("varname");
> {
> std::ofstream ofs( fileName.c_str() );
> boost::archive::text_oarchive oa( ofs );
> oa << saved;
> }
>

To

> int main()
> {
> std::string fileName = "test.txt";
> { // If this scope is commented out, crash goes away ???
         const Derived saved("varname");
> {
> std::ofstream ofs( fileName.c_str() );
> boost::archive::text_oarchive oa( ofs );
> oa << saved;
> }
>

EXPORT has been made a little bit more elabort to
separate issues of code instantiation for class registration. These
changes were necessary to make EXPORT work properly with
DLLS. Look at the 1.42 documentation for an explanation.

Robert Ramey


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