Created
November 8, 2011 09:08
-
-
Save CrBoy/1347333 to your computer and use it in GitHub Desktop.
A strange problem about BOOST_CLASS_EXPORT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "MyClass.h" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "MyClass.h" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char *argv[]) | |
{ | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment