Serialization valgrind reports errors in load() ...

Hello, I have following class which I want to serialize: template < class ValueType > class Values { private: vector< ValueType > _values; public: Values(unsigned p_nr, const ValueType& p_value) : _values(p_nr, p_value) {} Values() {} private: friend class boost::serialization::access; template < class Archive > void load(Archive& p_ar, unsigned /*p_version*/) { p_ar & _values; } template < class Archive > void save(Archive& p_ar, unsigned /*p_version*/) const { p_ar & _values; } BOOST_SERIALIZATION_SPLIT_MEMBER(); }; My main() looks very simple: ... // save const Values<std::string> a(3, "fritz"); { std::ofstream ofs("fritz.txt"); boost::archive::text_oarchive ar(ofs); ar << a; } // restore Values<std::string> b; { std::ifstream ifs("fritz.txt"); boost::archive::text_iarchive ar(ifs); ar >> b; } valgrind reports me following errors (the load() seems to be the problem): ==13202== Conditional jump or move depends on uninitialised value(s) ==13202== at 0x4E59F72: boost::archive::detail::basic_iarchive::reset_object_address(void const*, void const*) (in /usr/lib64/libboost_serialization.so.1.33.1) ==13202== by 0x408A2C: boost::serialization::stl::archive_input_seq<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> >
::operator()(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (collections_load_imp.hpp:54) ==13202== by 0x408ABD: void boost::serialization::stl::rebuild_collection<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> >, boost::serialization::stl::archive_input_seq<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > >, boost::serialization::stl::reserve_imp<std::vector<std::string, std::allocator<std::string> > > >(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (collections_load_imp.hpp:149) ==13202== by 0x408AF7: void boost::serialization::stl::load_collection<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> >, boost::serialization::stl::archive_input_seq<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > >, boost::serialization::stl::reserve_imp<std::vector<std::string, std::allocator<std::string> > > >(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (collections_load_imp.hpp:171) ==13202== by 0x408B1E: void boost::serialization::load<boost::archive::text_iarchive, std::string, std::allocator<std::string> >(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (vector.hpp:58) ==13202== by 0x408B5D: boost::serialization::free_loader<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > ::invoke(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (split_free.hpp:58) ==13202== by 0x408B87: void boost::serialization::split_free<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > (boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (split_free.hpp:74) ==13202== by 0x408BB1: void boost::serialization::serialize<boost::archive::text_iarchive, std::string, std::allocator<std::string> (boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (vector.hpp:76) ==13202== by 0x408BEF: void boost::serialization::serialize_adl<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > (boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (serialization.hpp:140) ==13202== by 0x408C29: boost::archive::detail::iserializer<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > ::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned) const (iserializer.hpp:160) ==13202== by 0x4E5A5B9: boost::archive::detail::basic_iarchive::load_object(void*, boost::archive::detail::basic_iserializer const&) (in /usr/lib64/libboost_serialization.so.1.33.1) ==13202== by 0x4095F7: boost::archive::detail::load_non_pointer_type<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > ::load_standard::invoke(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (iserializer.hpp:375) ==13202== ==13202== Conditional jump or move depends on uninitialised value(s) ==13202== at 0x4E59FA1: boost::archive::detail::basic_iarchive::reset_object_address(void const*, void const*) (in /usr/lib64/libboost_serialization.so.1.33.1) ==13202== by 0x408A2C: boost::serialization::stl::archive_input_seq<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > ::operator()(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (collections_load_imp.hpp:54) ==13202== by 0x408ABD: void boost::serialization::stl::rebuild_collection<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> >, boost::serialization::stl::archive_input_seq<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > >, boost::serialization::stl::reserve_imp<std::vector<std::string, std::allocator<std::string> > > >(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (collections_load_imp.hpp:149) ==13202== by 0x408AF7: void boost::serialization::stl::load_collection<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> >, boost::serialization::stl::archive_input_seq<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > >, boost::serialization::stl::reserve_imp<std::vector<std::string, std::allocator<std::string> > > >(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (collections_load_imp.hpp:171) ==13202== by 0x408B1E: void boost::serialization::load<boost::archive::text_iarchive, std::string, std::allocator<std::string> >(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (vector.hpp:58) ==13202== by 0x408B5D: boost::serialization::free_loader<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > ::invoke(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (split_free.hpp:58) ==13202== by 0x408B87: void boost::serialization::split_free<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > (boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (split_free.hpp:74) ==13202== by 0x408BB1: void boost::serialization::serialize<boost::archive::text_iarchive, std::string, std::allocator<std::string> (boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (vector.hpp:76) ==13202== by 0x408BEF: void boost::serialization::serialize_adl<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > (boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&, unsigned) (serialization.hpp:140) ==13202== by 0x408C29: boost::archive::detail::iserializer<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > ::load_object_data(boost::archive::detail::basic_iarchive&, void*, unsigned) const (iserializer.hpp:160) ==13202== by 0x4E5A5B9: boost::archive::detail::basic_iarchive::load_object(void*, boost::archive::detail::basic_iserializer const&) (in /usr/lib64/libboost_serialization.so.1.33.1) ==13202== by 0x4095F7: boost::archive::detail::load_non_pointer_type<boost::archive::text_iarchive, std::vector<std::string, std::allocator<std::string> > ::load_standard::invoke(boost::archive::text_iarchive&, std::vector<std::string, std::allocator<std::string> >&) (iserializer.hpp:375)
I don't see any mistakes in my client code. Seems to be a problem of the boost::serialization library. (I'm using boost 1.33.1) Should I create a bug entry for that, or is it already known? Regards, Sascha

Tell me what the change to the source code should be. Robert Ramey Sascha Ochsenknecht wrote:
I don't see any mistakes in my client code. Seems to be a problem of the boost::serialization library. (I'm using boost 1.33.1)
Should I create a bug entry for that, or is it already known?
Regards, Sascha

Hello Mr. Ramey, thanks for your reply. I didn't look to the internals of the serialization library so far. I first thought that the valgrind error came because of an error/mistake at my code. But I couldn't found anything, thats why I'm asking ... I just try to get my code valgrind-error free. I will have a closer look to it when I have more time. Thanks so far, Sascha Robert Ramey wrote:
Tell me what the change to the source code should be.
Robert Ramey
Sascha Ochsenknecht wrote:
I don't see any mistakes in my client code. Seems to be a problem of the boost::serialization library. (I'm using boost 1.33.1)
Should I create a bug entry for that, or is it already known?
Regards, Sascha

on Tue Jul 17 2007, "Robert Ramey" <ramey-AT-rrsd.com> wrote:
Tell me what the change to the source code should be.
Robert, Valgrind is very reliable (although it is possible for it to report false positives about uninitialized data) and the OP's test case looks simple enough to be considered minimal. If you can't find a problem with it, can you at least be looking at your implementation of reset_object_address to see if you can find a likely use of uninitialized data without making the OP debug unfamiliar code? -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com

I did take a cursory look at it and didn't see anything which would explain such a message. In fact, the implementation of reset_object_address is compiled into the library so I couldn't even see how such a thing could even be detected by just looking at the header. Of course the error message is pretty cryptic to my eye as I don't use that tool myself so it could well be the error message was misinterpreted. Robert Ramey David Abrahams wrote:
on Tue Jul 17 2007, "Robert Ramey" <ramey-AT-rrsd.com> wrote:
Tell me what the change to the source code should be.
Robert,
Valgrind is very reliable (although it is possible for it to report false positives about uninitialized data) and the OP's test case looks simple enough to be considered minimal. If you can't find a problem with it, can you at least be looking at your implementation of reset_object_address to see if you can find a likely use of uninitialized data without making the OP debug unfamiliar code?

on Tue Jul 17 2007, "Robert Ramey" <ramey-AT-rrsd.com> wrote:
I did take a cursory look at it and didn't see anything which would explain such a message. In fact, the implementation of reset_object_address is compiled into the library so I couldn't even see how such a thing could even be detected by just looking at the header.
It wasn't. Valgrind works at runtime. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com The Astoria Seminar ==> http://www.astoriaseminar.com

Good call, thanks a lot. Robert Ramey Peter Dimov wrote:
Robert Ramey wrote:
I did take a cursory look at it and didn't see anything which would explain such a message.
moveable_objects_recent is left uninitialized by the constructor.

well, its been there for years and you're the first one to detect it. Robert Ramey Sascha Ochsenknecht wrote:
Thanks to everyone.
Can anybody estimate the impact of that uninitialized member?
Regards, Sascha
Peter Dimov wrote:
moveable_objects_recent is left uninitialized by the constructor.
participants (4)
-
David Abrahams
-
Peter Dimov
-
Robert Ramey
-
Sascha Ochsenknecht