Re: [Boost-bugs] [Boost C++ Libraries] #5789: Segmentation fault with serialization when register_type rearranged

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #5789: Segmentation fault with serialization when register_type rearranged
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-08-16 19:25:55


#5789: Segmentation fault with serialization when register_type rearranged
---------------------------------------------------+------------------------
  Reporter: Krzysztof Tomaszewski <kt@…> | Owner: ramey
      Type: Bugs | Status: new
 Milestone: To Be Determined | Component: serialization
   Version: Boost 1.47.0 | Severity: Problem
Resolution: | Keywords:
---------------------------------------------------+------------------------

Comment (by Krzysztof Tomaszewski <kt@…>):

 Sorry for lack of proper formatting - here with formating:
 ----
 In our project we use boost-serialization to store objects by base-class
 pointer (boost::shared_ptr). We choose to register polymorphic classes by
 register_type method. So we have a template of a function which contains
 all class registrations like this:
 {{{
 template <class Archive>
 void RegisterDerivedClasses(Archive& ar) {
     ar.register_type((A*)0);
     ar.register_type((B*)0);
     ar.register_type((C*)0);
     //...
 }
 }}}
 This function template is called on each archive object before we use it.
 With development of the project we add new class registrations in this
 function template.

 The problem is a segmentation fault occuring in following situation:

 1. our program serializes some data with boost-serialization
 1. we add new class registration, so function RegisterDerivedClasses
 changes to something like this:
 {{{
 template <class Archive>
 void RegisterDerivedClasses(Archive& ar) {

     ar.register_type((NewClass?*)0);

     ar.register_type((A*)0);
     ar.register_type((B*)0);
     ar.register_type((C*)0);
     //...
 }
 }}}
 1. we recompile our project to produce the program
 1. the program tries to deserializes data produced in step 1 (no change in
 serialize methods) - '''HERE SEG-FAULT OCCURS'''

 =================================================================================

 BOST VERSION AND BUILD:

 This is occuring with Boost 1.47 and we checked this is occuring as well
 with 1.45.

 Our boost library is prepared with following steps:
 {{{
 ./bootstrap.sh --with-
 libraries=date_time,filesystem,serialization,system,thread,signals
 --prefix=/usr/local/boost/1.47
 ./b2 --layout=system variant=release link=static threading=multi
 }}}
 =================================================================================

 OS PLATFORM: Ubuntu 10.10, "uname -a" gives:

 Linux raU 2.6.38-10-generic-pae #44~lucid1-Ubuntu SMP Mon Jun 6 22:01:00
 UTC 2011 i686 GNU/Linux

 =================================================================================

 GCC: "g++ -v" gives:

 Using built-in specs. COLLECT_GCC=g++
 COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.5.1/lto-wrapper Target:
 i686-linux-gnu Configured with: ../src/configure -v --with-
 pkgversion='Ubuntu/Linaro? 4.5.1-7ubuntu2' --with-bugurl=
 file:///usr/share/doc/gcc-4.5/README.Bugs --enable-
 languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.5
 --enable-shared --enable-multiarch --enable-linker-build-id --with-system-
 zlib --libexecdir=/usr/lib --without-included-gettext --enable-
 threads=posix --with-gxx-include-dir=/usr/include/c++/4.5
 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
 --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
 --enable-gold --with-plugin-ld=ld.gold --enable-objc-gc --enable-
 targets=all --disable-werror --with-arch-32=i686 --with-tune=generic
 --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu
 --target=i686-linux-gnu Thread model: posix gcc version 4.5.1
 (Ubuntu/Linaro? 4.5.1-7ubuntu2)

 =================================================================================

 Compilation of the sample program:

 g++ test20.cpp -I /usr/local/boost/1.47/include/ -L
 /usr/local/boost/1.47/lib/ -lboost_serialization

 Running sample program:

 ./a.out

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5789#comment:2>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:07 UTC