Hi,
I'm having a bit of trouble while using
the serialization library. (Boost v1.35, gcc, Red Hat Linux).
I have a class containing a hash_map (key=string,
value=shared_ptr to a class containing a deque):
HashMapClass{
friend class
boost::serialization::access;
template <class
Archive>
void
serialize(Archive &ar, const unsigned in t version){
ar
& map;
}
__gun_cxx::hash_map<std::string const, boost::shared_ptr<DequeClass>
map;
}
//create instance
HashMapClass hashMap;
// fill hashmap
...
//perform serialization every hour or
something
std::ofstream ofs("file.txt");
boost::archive::binary_oarchive
oa(ofs);
const HashMapClass &map = hashMap;
oa << map;
The Problem:
This works fine for several saves. I can see the
file created changing each time the serialization is done. Then after about four
or five saves, it seg faults at the place described below. It looks to me like
it's having problems iterating over the hash_map.
Any advice on how to diagnose or fix this would be
appreciated,
Many thanks
Jack
Segfault at:
(__gnu_cxx::_Hashtable_const_iterator<std::pair<std::string const,
boost::shared_ptr<HashMapClass> >, std::string const,
__gnu_cxx::hash<std::string const>, std::_Select1st<std::pair<std
string const, boost::shared_ptr<HashMapClass> > >,
std::equal_to<std::string const>,
std::allocator<boost::shared_ptr<HashMapClass> >
>::operator++()+0xe)[0x65a825a]
(boost::archive::detail::oserializer<boost::archive::binary_oarchive,
__gnu_cxx::hash_map<std::string const, boost::shared_ptr<HashMapClass>,
__gnu_cxx::hash<std::string const>, std::equal_to<std::string
const>, std::allocator<boost::shared_ptr<HashMapClass> >
>::save_object_data(boost::archive::detail::basic_oarchive&,
void const*) const+0x1b2)[0x65a90da]
(/usr/lib/libboost_serialization-gcc34-mt-1_35.so.1.35.0(boost::archive::detail::basic_oarchive_impl::save_object(boost::archive::detail::basic_oarchive&,
void const*, boost::archive::detail::basic_oserializer
const&)+0xd1)[0x8497cd]
(/usr/lib/libboost_serialization-gcc34-mt-1_35.so.1.35.0(boost::archive::detail::basic_oarchive::save_object(void
const*, boost::archive::detail::basic_oserializer
const&)+0x23)[0x849213]
(boost::archive::detail::oserializer<boost::archive::binary_oarchive,
HashMapClass>::save_object_data(boost::archive::detail::basic_oarchive&,
void const*) const+0x15c)[0x65a7db4]
(/usr/lib/libboost_serialization-gcc34-mt-1_35.so.1.35.0(boost::archive::detail::basic_oarchive_impl::save_object(boost::archive::detail::basic_oarchive&,
void const*, boost::archive::detail::basic_oserializer
const&)+0xd1)[0x8497cd]
(/usr/lib/libboost_serialization-gcc34-mt-1_35.so.1.35.0(boost::archive::detail::basic_oarchive::save_object(void
const*, boost::archive::detail::basic_oserializer
const&)+0x23)[0x849213]