Re: [Boost-bugs] [Boost C++ Libraries] #3747: Serialization code speculate in order of static initialization (was: Not possible to split derived classes in several files)

Subject: Re: [Boost-bugs] [Boost C++ Libraries] #3747: Serialization code speculate in order of static initialization (was: Not possible to split derived classes in several files)
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-03-26 14:07:35


#3747: Serialization code speculate in order of static initialization
--------------------------------------------------+-------------------------
  Reporter: Runar Undheim <r.undheim@…> | Owner: ramey
      Type: Bugs | Status: reopened
 Milestone: Boost 1.43.0 | Component: serialization
   Version: Boost 1.41.0 | Severity: Showstopper
Resolution: | Keywords: serialization static order
--------------------------------------------------+-------------------------
Changes (by Runar Undheim <r.undheim@…>):

  * keywords: => serialization static order
  * severity: Problem => Showstopper
  * milestone: Boost 1.42.0 => Boost 1.43.0

Comment:

 Use project from attached zip-file (SerializationBug1.zip).
 If I set CLASS_EXPORT_IN_MAIN define to 0 then it fails. It I set it to 1
 then everything works nicely. This define changes the file where the
 classes are registered:

 In main.cpp:

 {{{
 #include "SerializationClasses.hpp"

 #if CLASS_EXPORT_IN_MAIN
   BOOST_CLASS_EXPORT(Object)
   BOOST_CLASS_EXPORT(Main)
 #endif
 }}}

 In serializationRegistration.cpp:

 {{{
 #include "serializationClasses.hpp"

 #if !CLASS_EXPORT_IN_MAIN
   BOOST_CLASS_EXPORT(Object)
   BOOST_CLASS_EXPORT(Main)
 #endif
 }}}

 The only difference I can see is the order of the static initialization.

 When code fail (order_of_static_registration_fail.txt):

 {{{
 boost::serialization::singleton<boost::archive::detail::oserializer<boost::archive::text_oarchive,Main>
>::instance''(void)
 boost::serialization::singleton<boost::serialization::extended_type_info_typeid<Main>
>::instance''(void)
 boost::serialization::singleton<boost::serialization::void_cast_detail::void_caster_primitive<Main,Base>
>::instance''(void)
 ...
 }}}

 When code is working (order_of_static_registration_ok.txt):

 {{{
 boost::archive::detail::`anonymous
 namespace'::init_guid<Object>::g''(void)
 boost::archive::detail::`anonymous namespace'::init_guid<Main>::g''(void)
 boost::serialization::singleton<boost::archive::detail::`anonymous
 namespace'::guid_initializer<Object> >::instance''(void)
 ...
 }}}

 The code seems to speculate in the order of the static initialization. The
 code should be updated to handle when static initialization come in this
 order.

 Runar Undheim

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/3747#comment:10>
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:02 UTC