public
Created

A strange problem about BOOST_CLASS_EXPORT

  • Download Gist
MyClass.h
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#ifndef MYCLASS_H
#define MYCLASS_H
 
#include <boost/serialization/export.hpp>
#include <boost/serialization/vector.hpp>
 
using namespace std;
 
class A
{
public:
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
}
};
 
class A_child: public A
{
public:
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & boost::serialization::base_object<A>(*this);
}
};
BOOST_CLASS_EXPORT(A_child)
 
 
class B
{
public:
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
}
};
 
class B_child: public B
{
public:
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
ar & boost::serialization::base_object<B>(*this);
}
};
BOOST_CLASS_EXPORT(B_child)
 
 
#endif
README
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
This problem seems to be a boost bug. I am not sure but if I execute this code, it crashes at the end of main().
 
My build environment is Ubuntu 10.04 64-bit server (kernel 2.6.32), gcc 4.4.3, boost 1.40. Another machine with CentOS (kernel 2.6.18), gcc 4.1.2, and boost 1.41 goes well.
 
Backtrace is as follows:
 
(gdb) bt
#0 __strcmp_ssse3 () at ../sysdeps/x86_64/multiarch/../strcmp.S:100
#1 0x00007ffff7bac002 in boost::serialization::detail::key_compare::operator() (this=0x606260) at libs/serialization/src/extended_type_info.cpp:60
#2 std::_Rb_tree<boost::serialization::extended_type_info const*, boost::serialization::extended_type_info const*, std::_Identity<boost::serialization::extended_type_info const*>, boost::serialization::detail::key_compare, std::allocator<boost::serialization::extended_type_info const*> >::_M_upper_bound (this=0x606260) at /usr/include/c++/4.4/bits/stl_tree.h:1018
#3 std::_Rb_tree<boost::serialization::extended_type_info const*, boost::serialization::extended_type_info const*, std::_Identity<boost::serialization::extended_type_info const*>, boost::serialization::detail::key_compare, std::allocator<boost::serialization::extended_type_info const*> >::upper_bound (this=0x606260) at /usr/include/c++/4.4/bits/stl_tree.h:753
#4 std::multiset<boost::serialization::extended_type_info const*, boost::serialization::detail::key_compare, std::allocator<boost::serialization::extended_type_info const*> >::upper_bound (this=0x606260)
at /usr/include/c++/4.4/bits/stl_multiset.h:570
#5 boost::serialization::extended_type_info::key_unregister (this=0x606260) at libs/serialization/src/extended_type_info.cpp:104
#6 0x00007ffff7bac4c2 in ~extended_type_info (this=0x4026af, __in_chrg=<value optimized out>) at libs/serialization/src/extended_type_info.cpp:150
#7 0x00000000004017f0 in ~extended_type_info_typeid (this=0x606260, __in_chrg=<value optimized out>) at /usr/include/boost/serialization/extended_type_info_typeid.hpp:80
#8 0x00000000004019ac in ~singleton_wrapper (this=0x606260, __in_chrg=<value optimized out>) at /usr/include/boost/serialization/singleton.hpp:104
#9 0x00007ffff7074262 in __run_exit_handlers (status=0) at exit.c:78
#10 *__GI_exit (status=0) at exit.c:100
#11 0x00007ffff7059c54 in __libc_start_main (main=<value optimized out>, argc=<value optimized out>, ubp_av=<value optimized out>, init=<value optimized out>, fini=<value optimized out>,
rtld_fini=<value optimized out>, stack_end=0x7fffffffe908) at libc-start.c:258
#12 0x0000000000400fe9 in _start ()
 
Compile the code using such a command line: `g++ -Wall -g3 -O0 -o program main.cpp f1.cpp f2.cpp -lboost_serialization`
f1.cpp
C++
1
#include "MyClass.h"
f2.cpp
C++
1
#include "MyClass.h"
main.cpp
C++
1 2 3
int main(int argc, char *argv[])
{
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.