[Boost-bugs] [ boost-Bugs-1262084 ] crash deserializing 1.32 data (poly archive + stl container)

Bugs item #1262084, was opened at 2005-08-17 06:31 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1262084&group_id=7586 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: serialization Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Robert Ramey (ramey) Summary: crash deserializing 1.32 data (poly archive + stl container) Initial Comment: Hello, i got a problem deserializing STL containers with polymorphic archive interfaces. Serialization/Deserialization with boost 1.32 works fine. Simple object trees with stl containers (maps) and base class registration (no shared_ptr used). When i deserialize the data (xml) with boost 1.33 it asserts/crashes in basic_iarchive.cpp ( basic_iarchive_impl::reset_object_address): --- snip ---- inline void basic_iarchive_impl::reset_object_address( const void * new_address, const void *old_address ){ // if the this object wasn't tracked std::size_t i = moveable_object_position; if(i >= moveable_object_stack.size()) return; if(old_address != object_id_vector[i].address) // skip to any lower level ones ++i; while(i < moveable_object_stack.size()){ // calculate displacement from this level assert(object_id_vector[i].address >= old_address); <---- assert here !!! // warning - pointer arithmetic on void * is in herently non-portable // but expected to work on all platforms in current usage std::size_t member_displacement = reinterpret_cast<std::size_t>(object_id_vector[i].address) - reinterpret_cast<std::size_t>(old_address); ---- snip ---- Callstack:
::reset_object_address(const void * new_address=0x00fb67cc, const void *
ddc.exe!boost::archive::detail::basic_iarchive_impl::reset_object_address(const void * new_address=0x00fb67cc, const void * old_address=0x0135c67c) Line 266 + 0x2a C++ ddc.exe!boost::archive::detail::basic_iarchive::reset_object_address(const void * new_address=0x00fb67cc, const void * old_address=0x0135c67c) Line 530 C++ ddc.exe!boost::archive::detail::polymorphic_iarchive_impl<boost::archive::xml_iarchive_impl<boost::archive::xml_iarchive> old_address=0x0135c67c) Line 78 C++ ddc.exe!boost::serialization::stl::archive_input_map<boost::archive::polymorphic_iarchive,std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> > >
::operator()(boost::archive::polymorphic_iarchive & ar={...}, std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> > > & s={...}) Line 118 + 0x1a C++
ddc.exe!boost::serialization::stl::rebuild_collection<boost::archive::polymorphic_iarchive,std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> >
,boost::serialization::stl::archive_input_map<boost::archive::polymorphic_iarchive,std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> > > ,boost::serialization::stl::no_reserve_imp<std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,minimon::base::display::dispman::CLayoutObject *> > >
(boost::archive::polymorphic_iarchive & ar={...}, std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> > > & s={...}) Line 209 C++
ddc.exe!boost::serialization::stl::load_collection<boost::archive::polymorphic_iarchive,std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> >
,boost::serialization::stl::archive_input_map<boost::archive::polymorphic_iarchive,std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> > > ,boost::serialization::stl::no_reserve_imp<std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> > > > (boost::archive::polymorphic_iarchive & ar={...}, std::map<unsigned int,xxx::LayoutObject *,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,xxx::LayoutObject *> > > & s={...}) Line 230 + 0xd C++
---- The serializing code is implemented using split members and manual registration and usually read like this: ---- snip --- void DerivedLayoutObject::serialize( boost::archive::polymorphic_oarchive& ar, const unsigned int /* version */) { // register pointer type info ar.register_type(static_cast<LayoutObject*>(0)); // serialize data members ar & boost::serialization::make_nvp( "status", m_status); .... // serialize stl container (std::map here) ar & boost::serialization::make_nvp( "childs", m_childs); } (deserialization vise-versa) --------------------- Whats the problem here? I simply rebuilt the whole project using 1.33. Regards, A. Focht ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1262084&group_id=7586 ------------------------------------------------------- SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf _______________________________________________ Boost-bugs mailing list Boost-bugs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/boost-bugs

Here are some code that illustrates problem. This crashes when deserializing 1.33 data, however. Programm faults with count >= 2946 on MS VC 7.1 debug build. Compilation options: /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /GS /Zc:wchar_t /Zc:forScope /GR /Yu"stdafx.h" /Fp"Debug/reset_ptr_err.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /Zi /TP #define BOOST_SERIALIZATION_DYN_LINK #include <boost/archive/polymorphic_iarchive.hpp> #include <boost/archive/polymorphic_oarchive.hpp> #include <boost/serialization/export.hpp> #include <sstream> #include <boost/archive/polymorphic_text_iarchive.hpp> #include <boost/archive/polymorphic_text_oarchive.hpp> #include <boost/archive/polymorphic_xml_iarchive.hpp> #include <boost/archive/polymorphic_xml_oarchive.hpp> #include <boost/archive/polymorphic_binary_iarchive.hpp> #include <boost/archive/polymorphic_binary_oarchive.hpp> #include <boost/serialization/vector.hpp> struct A { virtual ~A() = 0 {} void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version) {} void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version) {} }; const int count = 100000; struct B : A { std::vector<int> v_; void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(A); ar & BOOST_SERIALIZATION_NVP(v_); } void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(A); ar & BOOST_SERIALIZATION_NVP(v_); } B() { for (int i = 0; i < count; ++i) v_.push_back(i); } }; struct C : B { void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(B); } void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(B); } }; BOOST_IS_ABSTRACT(A) BOOST_CLASS_EXPORT(B) BOOST_CLASS_EXPORT(C) int main(int argc, char* argv[]) { C c; std::stringstream ss; { boost::archive::polymorphic_binary_oarchive oa(ss); oa & BOOST_SERIALIZATION_NVP(c); } { boost::archive::polymorphic_binary_iarchive ia(ss); ia >> BOOST_SERIALIZATION_NVP(c); } return 0; } "SourceForge.net" <noreply@sourceforge.net> wrote: news:E1E5O0t-0004my-Ng@sc8-sf-web1.sourceforge.net...
Bugs item #1262084, was opened at 2005-08-17 06:31 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1262084&group_id=7586
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: serialization Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Robert Ramey (ramey) Summary: crash deserializing 1.32 data (poly archive + stl container)
Initial Comment: Hello,
i got a problem deserializing STL containers with polymorphic archive interfaces.
Serialization/Deserialization with boost 1.32 works fine. Simple object trees with stl containers (maps) and base class registration (no shared_ptr used).
When i deserialize the data (xml) with boost 1.33 it asserts/crashes in basic_iarchive.cpp ( basic_iarchive_impl::reset_object_address):
--- snip ----
inline void basic_iarchive_impl::reset_object_address( const void * new_address, const void *old_address ){ // if the this object wasn't tracked std::size_t i = moveable_object_position; if(i >= moveable_object_stack.size()) return; if(old_address != object_id_vector[i].address) // skip to any lower level ones ++i; while(i < moveable_object_stack.size()){ // calculate displacement from this level assert(object_id_vector[i].address >= old_address); <---- assert here !!! // warning - pointer arithmetic on void * is in herently non-portable // but expected to work on all platforms in current usage std::size_t member_displacement = reinterpret_cast<std::size_t>(object_id_vector[i].address) - reinterpret_cast<std::size_t>(old_address);
---- snip ----

Also, this looks like that this error can't be corrected just by changing member_displacement to signed type or doing something similar. Without covering polymorhic classes execution of reset_object_address never goes further than "if(i >= moveable_object_stack.size()) return;", in my example it does. "Sergey Skorniakov" <s.skorniakov@megaputer.ru> wrote: news:df4cge$ogh$1@sea.gmane.org...
Here are some code that illustrates problem. This crashes when deserializing 1.33 data, however. Programm faults with count >= 2946 on MS VC 7.1 debug build. Compilation options: /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Gm /EHsc /RTC1 /MDd /GS /Zc:wchar_t /Zc:forScope /GR /Yu"stdafx.h" /Fp"Debug/reset_ptr_err.pch" /Fo"Debug/" /Fd"Debug/vc70.pdb" /W3 /nologo /c /Wp64 /Zi /TP
#define BOOST_SERIALIZATION_DYN_LINK #include <boost/archive/polymorphic_iarchive.hpp> #include <boost/archive/polymorphic_oarchive.hpp> #include <boost/serialization/export.hpp>
#include <sstream>
#include <boost/archive/polymorphic_text_iarchive.hpp> #include <boost/archive/polymorphic_text_oarchive.hpp>
#include <boost/archive/polymorphic_xml_iarchive.hpp> #include <boost/archive/polymorphic_xml_oarchive.hpp>
#include <boost/archive/polymorphic_binary_iarchive.hpp> #include <boost/archive/polymorphic_binary_oarchive.hpp>
#include <boost/serialization/vector.hpp>
struct A { virtual ~A() = 0 {}
void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version) {} void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version) {} };
const int count = 100000;
struct B : A { std::vector<int> v_; void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(A); ar & BOOST_SERIALIZATION_NVP(v_); } void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(A); ar & BOOST_SERIALIZATION_NVP(v_); } B() { for (int i = 0; i < count; ++i) v_.push_back(i); } };
struct C : B { void serialize(boost::archive::polymorphic_iarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(B); } void serialize(boost::archive::polymorphic_oarchive & ar, const unsigned int file_version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(B); } };
BOOST_IS_ABSTRACT(A) BOOST_CLASS_EXPORT(B) BOOST_CLASS_EXPORT(C)
int main(int argc, char* argv[]) { C c;
std::stringstream ss; { boost::archive::polymorphic_binary_oarchive oa(ss); oa & BOOST_SERIALIZATION_NVP(c); } { boost::archive::polymorphic_binary_iarchive ia(ss); ia >> BOOST_SERIALIZATION_NVP(c); } return 0; }
"SourceForge.net" <noreply@sourceforge.net> wrote: news:E1E5O0t-0004my-Ng@sc8-sf-web1.sourceforge.net...
Bugs item #1262084, was opened at 2005-08-17 06:31 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=107586&aid=1262084&group_id=7586
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: serialization Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nobody/Anonymous (nobody) Assigned to: Robert Ramey (ramey) Summary: crash deserializing 1.32 data (poly archive + stl container)
Initial Comment: Hello,
i got a problem deserializing STL containers with polymorphic archive interfaces.
Serialization/Deserialization with boost 1.32 works fine. Simple object trees with stl containers (maps) and base class registration (no shared_ptr used).
When i deserialize the data (xml) with boost 1.33 it asserts/crashes in basic_iarchive.cpp ( basic_iarchive_impl::reset_object_address):
--- snip ----
inline void basic_iarchive_impl::reset_object_address( const void * new_address, const void *old_address ){ // if the this object wasn't tracked std::size_t i = moveable_object_position; if(i >= moveable_object_stack.size()) return; if(old_address != object_id_vector[i].address) // skip to any lower level ones ++i; while(i < moveable_object_stack.size()){ // calculate displacement from this level assert(object_id_vector[i].address >= old_address); <---- assert here !!! // warning - pointer arithmetic on void * is in herently non-portable // but expected to work on all platforms in current usage std::size_t member_displacement = reinterpret_cast<std::size_t>(object_id_vector[i].address) - reinterpret_cast<std::size_t>(old_address);
---- snip ----
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
participants (2)
-
Sergey Skorniakov
-
SourceForge.net