Boost logo

Boost Testing :

From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2005-07-12 06:55:45


Robert Ramey wrote:

> I believe that here is where the problem starts:
>
> Note: line numbers slightly off
>
> Oserializer.hpp(460)
> const basic_pointer_oserializer * bpos_ptr = register_type(ar, * t)
> // returns NULL
> Since T is B which is not abstract - the above calls
>
> Interface_oarchive.hpp(60)
> template<class T>
> const basic_pointer_oserializer * register_type(const T * t = NULL){
> const basic_pointer_oserializer & bpos =
> instantiate_pointer_oserializer(
> static_cast<Archive *>(NULL),
> static_cast<T *>(NULL)
> );
>
> this->This()->register_basic_serializer(bpos.get_basic_serializer());
> return & bpos;
> }

[snip]

Hmm, it's a different test (test_registered_text_archive instead of
test_derived_class_ptr_text_archive), but nevertheless I think I found the
reason of the crash:

Archive=boost::archive::text_iarchive, T=polymorphic_derived1,
iserializer=1400b2b40
Archive=boost::archive::text_iarchive, T=polymorphic_derived2,
iserializer=1400b2ba0
Archive=boost::archive::text_oarchive, T=polymorphic_derived1,
oserializer=1400b2bb8
Archive=boost::archive::text_oarchive, T=polymorphic_derived2,
oserializer=1400b2be8
Archive=boost::archive::text_oarchive, T=polymorphic_derived1, const
pointer_oserializer<T, Archive> pointer_oserializer<T,
Archive>::instance=1400b19d0
Archive=boost::archive::text_oarchive, T=polymorphic_derived1,
oserializer=1400b2bb8
Archive=boost::archive::text_oarchive, T=polymorphic_derived2, const
pointer_oserializer<T, Archive> pointer_oserializer<T,
Archive>::instance=1400b19f0
Archive=boost::archive::text_oarchive, T=polymorphic_derived2,
oserializer=1400b2be8
basic_pointer_oserializer *
register_type<polymorphic_derived1>(boost::archive::text_oarchive
&ar=11fffafc0, ...)
basic_pointer_oserializer *
abstract<polymorphic_derived1>::register_type(boost::archive::text_oarchive &)
unknown location(0): fatal error in "test_main_caller( argc, argv )":
signal: memory access violation

Looks like polymorphic_derived1 is classified as abstract. This points to
the following code as the root of the problem:

typedef
   BOOST_DEDUCED_TYPENAME mpl::eval_if<
     is_abstract<T>,
     mpl::identity<abstract<T> >,
     mpl::identity<non_abstract<T> >
>::type typex;

Digging deeper, this leads us to the fact that is_abstract is defined as

#ifndef BOOST_NO_IS_ABSTRACT
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_abstract,T,::boost::detail::is_abstract_imp<T>::value)
#else
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_abstract,T,::boost::detail::is_polymorphic_imp<T>::value)
#endif

and from common_edg.hpp:

#if (__EDG_VERSION__ < 300) && !defined(BOOST_NO_IS_ABSTRACT)
# define BOOST_NO_IS_ABSTRACT
#endif

Duh! I wonder if it's a wise choice to map is_abstract to is_polymorphic...
But anyway, seems like serialization/is_abstract.hpp needs some tuning. Why
don't you rely on BOOST_NO_IS_ABSTRACT in this header?

Markus


Boost-testing list run by mbergal at meta-comm.com