[serialization] Assertion `new_cid == cid' failed - fails on gcc, works on msvc
Hi, I am serializing/deserializing a polymorphic class and I am having the above issue upon deserialization where it fails on gcc and works in msvc. The serializer and deserializer are implemented in two different executables. Should that be an issue? All the object files *except* the serialize/deserialize/main functions are the same in both executables. In the gcc case, its comparing new_cid=2 against cid=1 (if that helps at all!) TIA, Sohail
Ok to rule out the different executables being the issue (thought typeid might be the issue), I've made them into one executable. Still no difference though. -----Original Message----- From: boost-users-bounces@lists.boost.org on behalf of Sohail Somani Sent: Mon 3/26/2007 9:13 PM To: boost-users@lists.boost.org Subject: [Boost-users] [serialization] Assertion `new_cid == cid' failed -fails on gcc, works on msvc Hi, I am serializing/deserializing a polymorphic class and I am having the above issue upon deserialization where it fails on gcc and works in msvc. The serializer and deserializer are implemented in two different executables. Should that be an issue? All the object files *except* the serialize/deserialize/main functions are the same in both executables. In the gcc case, its comparing new_cid=2 against cid=1 (if that helps at all!)
Things to try: a) does it work with non-polymorphic archives of the same type: binary? etc. That is, can you check to see if its an issue with "polymophic-ness" or not. b) try serializtion to xml_oarchive and save the output. check to see that you can read it. Then try polymorphic_xml_oarchive and compare the two. Robert Ramey Sohail Somani wrote:
Hi,
I am serializing/deserializing a polymorphic class and I am having the above issue upon deserialization where it fails on gcc and works in msvc. The serializer and deserializer are implemented in two different executables. Should that be an issue? All the object files *except* the serialize/deserialize/main functions are the same in both executables.
In the gcc case, its comparing new_cid=2 against cid=1 (if that helps at all!)
TIA,
Sohail
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 10:18 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid == cid' failed-fails on gcc, works on msvc
Things to try:
a) does it work with non-polymorphic archives of the same type: binary? etc. That is, can you check to see if its an issue with "polymophic-ness" or not. b) try serializtion to xml_oarchive and save the output. check to see that you can read it. Then try polymorphic_xml_oarchive and compare the two.
Hi Robert, Thank you for your response. In my example, the archives are not polymorphic, the class I am serializing *is* polymorphic. I think I've narrowed it down to stripping out the use of shared_ptr (i.e., without it, it "works") but I'm going to try for a smaller example. Sohail
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp Robert Ramey Sohail Somani wrote:
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 10:18 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid == cid' failed-fails on gcc, works on msvc
Things to try:
a) does it work with non-polymorphic archives of the same type: binary? etc. That is, can you check to see if its an issue with "polymophic-ness" or not. b) try serializtion to xml_oarchive and save the output. check to see that you can read it. Then try polymorphic_xml_oarchive and compare the two.
Hi Robert,
Thank you for your response. In my example, the archives are not polymorphic, the class I am serializing *is* polymorphic.
I think I've narrowed it down to stripping out the use of shared_ptr (i.e., without it, it "works") but I'm going to try for a smaller example.
Sohail
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
Ah thanks for the pointer (no pun intended!) I'll let you know how that goes.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
I think I've followed the documentation, but the attached test still triggers an assertion when deserializing on gcc 3.2.2: $ ./build/stage/bin/test_serialize Serialized form: 22 serialization::archive 3 0 1 2 7 derived 1 0 0 1 0 1 10 derived id test_serialize: basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive ::detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer*(*)(const boost::serialization::extended_type_info&)): Assertion `new_cid == cid' failed. Aborted This assertion does not trigger occur on Visual C++ 7.1. Can you spot if I'm doing something obviously silly? TIA, Sohail
Ok I got a bit further on this. In the example I attached earlier, if I make the base class non-abstract and remove the BOOST_IS_ABSTRACT(base) specialization, it "works". However this will kill the use of serialization for me :-( Is is_abstract<base> interacting in a mean way with shared_ptr? PS: Sorry for the post format, can't figure out outlook webmail -----Original Message----- From: boost-users-bounces@lists.boost.org on behalf of Sohail Somani Sent: Tue 3/27/2007 4:12 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid==cid'failed-fails on gcc, works on msvc
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
I think I've followed the documentation, but the attached test still triggers an assertion when deserializing on gcc 3.2.2: $ ./build/stage/bin/test_serialize Serialized form: 22 serialization::archive 3 0 1 2 7 derived 1 0 0 1 0 1 10 derived id test_serialize: basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive ::detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer*(*)(const boost::serialization::extended_type_info&)): Assertion `new_cid == cid' failed. Aborted This assertion does not trigger occur on Visual C++ 7.1. Can you spot if I'm doing something obviously silly?
OK
Try the following:
//BOOST_CLASS_EXPORT(base);
BOOST_CLASS_EXPORT(derived);
#include
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
I think I've followed the documentation, but the attached test still triggers an assertion when deserializing on gcc 3.2.2:
$ ./build/stage/bin/test_serialize Serialized form: 22 serialization::archive 3 0 1 2 7 derived 1 0 0 1 0 1 10 derived id test_serialize: basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive
detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer*(*)(const boost::serialization::extended_type_info&)): Assertion `new_cid == cid' failed. Aborted
This assertion does not trigger occur on Visual C++ 7.1. Can you spot if I'm doing something obviously silly?
TIA,
Sohail
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Nope, same thing. Is there a way to enable some debug traces of the serialization? Inspection by debugging isn't helping much. What does the serialization library do differently for abstract classes? The part that is still confusing me is that I only have these issues when serializing shared_ptr. Raw pointers work just fine.
-----Original Message-----
From: boost-users-bounces@lists.boost.org on behalf of Robert Ramey
Sent: Tue 3/27/2007 10:28 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [serialization] Assertion`new_cid==cid'failed-fails on gcc, works on msvc
OK
Try the following:
//BOOST_CLASS_EXPORT(base);
BOOST_CLASS_EXPORT(derived);
#include
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
I think I've followed the documentation, but the attached test still triggers an assertion when deserializing on gcc 3.2.2:
$ ./build/stage/bin/test_serialize Serialized form: 22 serialization::archive 3 0 1 2 7 derived 1 0 0 1 0 1 10 derived id test_serialize: basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive
detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer*(*)(const boost::serialization::extended_type_info&)): Assertion `new_cid == cid' failed. Aborted
This assertion does not trigger occur on Visual C++ 7.1. Can you spot if I'm doing something obviously silly?
RE: [Boost-users] [serialization] Assertion`new_cid==cid'failed-fails on gcc, works on msvcHmm - I'm not sure which version of boost you're using.
For boost version 1.32 one needs to use
BOOST_SHARED_POINTER_EXPORT(T)
This requirement was eliminated in 1.33 onward but I'm not sure which version you're using.
Robert Ramey
"Sohail Somani"
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
I think I've followed the documentation, but the attached test still triggers an assertion when deserializing on gcc 3.2.2:
$ ./build/stage/bin/test_serialize Serialized form: 22 serialization::archive 3 0 1 2 7 derived 1 0 0 1 0 1 10 derived id test_serialize: basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive
detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer*(*)(const boost::serialization::extended_type_info&)): Assertion `new_cid == cid' failed. Aborted
This assertion does not trigger occur on Visual C++ 7.1. Can you spot if I'm doing something obviously silly?
------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I'm using 1.33.1. If I use serialization/shared_ptr_132.hpp, same issue. Does the test fail for you?
-----Original Message-----
From: boost-users-bounces@lists.boost.org on behalf of Robert Ramey
Sent: Wed 3/28/2007 1:15 AM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users][serialization]Assertion`new_cid==cid'failed-fails on gcc,works on msvc
RE: [Boost-users] [serialization] Assertion`new_cid==cid'failed-fails on gcc, works on msvcHmm - I'm not sure which version of boost you're using.
For boost version 1.32 one needs to use
BOOST_SHARED_POINTER_EXPORT(T)
This requirement was eliminated in 1.33 onward but I'm not sure which version you're using
Robert Ramey
"Sohail Somani"
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a little bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
I think I've followed the documentation, but the attached test still triggers an assertion when deserializing on gcc 3.2.2:
$ ./build/stage/bin/test_serialize Serialized form: 22 serialization::archive 3 0 1 2 7 derived 1 0 0 1 0 1 10 derived id test_serialize: basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive
detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer*(*)(const boost::serialization::extended_type_info&)): Assertion `new_cid == cid' failed. Aborted
This assertion does not trigger occur on Visual C++ 7.1. Can you spot if I'm doing something obviously silly?
------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Currently I only have the HEAD and RC_1_34 on my system and can't run a gcc test. I did build and compile and test with vc 7.1 and found no problems. Try serializing your test to xml archive. That will make the details a lot more visible. Sohail Somani wrote:
I'm using 1.33.1. If I use serialization/shared_ptr_132.hpp, same issue. Does the test fail for you?
-----Original Message----- From: boost-users-bounces@lists.boost.org on behalf of Robert Ramey Sent: Wed 3/28/2007 1:15 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users][serialization]Assertion`new_cid==cid'failed-fails on gcc,works on msvc
RE: [Boost-users] [serialization] Assertion`new_cid==cid'failed-fails on gcc, works on msvcHmm - I'm not sure which version of boost you're using.
For boost version 1.32 one needs to use
BOOST_SHARED_POINTER_EXPORT(T)
This requirement was eliminated in 1.33 onward but I'm not sure which version you're using
Robert Ramey
"Sohail Somani"
wrote in message news:1C1EBEF8DBACDC439D038EA051674EC73EE10C@xbox.financialcad.com... Nope, same thing. Is there a way to enable some debug traces of the serialization? Inspection by debugging isn't helping much. What does the serialization library do differently for abstract classes? The part that is still confusing me is that I only have these issues when serializing shared_ptr. Raw pointers work just fine. -----Original Message----- From: boost-users-bounces@lists.boost.org on behalf of Robert Ramey Sent: Tue 3/27/2007 10:28 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion`new_cid==cid'failed-fails on gcc, works on msvc
OK
Try the following:
//BOOST_CLASS_EXPORT(base);
BOOST_CLASS_EXPORT(derived);
#include
//BOOST_SERIALIZATION_SHARED_PTR(base);
BOOST_SERIALIZATION_SHARED_PTR(derived);
The base class shouldn't need exporting as it never
directly instantiated.
Robert Ramey
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Tuesday, March 27, 2007 2:39 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] [serialization] Assertion `new_cid ==cid'failed-fails on gcc, works on msvc
Note that serialize a poly morphic shared pointer requires a
Sohail Somani wrote: little
bit of gymnastics. Check out the "test_shared_ptr" and the source of serialization/shared_ptr.hpp
I think I've followed the documentation, but the attached test still triggers an assertion when deserializing on gcc 3.2.2:
$ ./build/stage/bin/test_serialize Serialized form: 22 serialization::archive 3 0 1 2 7 derived 1 0 0 1 0 1 10 derived id test_serialize: basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer*
boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archive
detail::basic_iarchive&, void*&, const boost::archive::detail::basic_pointer_iserializer*, const boost::archive::detail::basic_pointer_iserializer*(*)(const boost::serialization::extended_type_info&)): Assertion `new_cid == cid' failed. Aborted
This assertion does not trigger occur on Visual C++ 7.1. Can you spot if I'm doing something obviously silly?
------------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hmm. Unfortunate... I wonder if anyone else would be willing to try it? Maybe I should try a later compiler.
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Wednesday, March 28, 2007 9:20 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users][serialization]Assertion`new_cid==cid'failed-fail s on gcc,works on msvc
Currently I only have the HEAD and RC_1_34 on my system and can't run a gcc test. I did build and compile and test with vc 7.1 and found no problems.
Try serializing your test to xml archive. That will make the details a lot more visible.
Sohail Somani wrote:
I'm using 1.33.1. If I use serialization/shared_ptr_132.hpp, same issue. Does the test fail for you?
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Wednesday, March 28, 2007 9:20 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users][serialization]Assertion`new_cid==cid'failed-fail s on gcc,works on msvc
Currently I only have the HEAD and RC_1_34 on my system and can't run a gcc test. I did build and compile and test with vc 7.1 and found no problems.
Try serializing your test to xml archive. That will make the details a lot more visible.
I wonder if you want to add my test to your suite. When I added it to libs/serialization/test, it fails to run on gcc 3.2. Still haven't tried newer compiler - meetings all day :-( Sohail
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Wednesday, March 28, 2007 9:20 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users][serialization]Assertion`new_cid==cid'failed-fail s on gcc,works on msvc
Currently I only have the HEAD and RC_1_34 on my system and can't run a gcc test. I did build and compile and test with vc 7.1 and found no problems.
Try serializing your test to xml archive. That will make the details a lot more visible.
Thanks for your suggestion. It seems the class_id's are reversed and that tracking_level=0! Is that a clue? Wieeeeeerd! XML output:
From gcc 3.2:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
From Visual C++ 7.1:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Sohail Somani
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey
Try serializing your test to xml archive. That will make the details a lot more visible.
Thanks for your suggestion. It seems the class_id's are reversed and that tracking_level=0! Is that a clue? Wieeeeeerd!
[xml output for vc71 and gcc32 snipped] If I load from the archive in gcc32 using the xml string from vc71, it works. So it seems that for some odd reason, gcc is generating the wrong id's to begin with.
Sohail Somani wrote:
Thanks for your suggestion. It seems the class_id's are reversed and that tracking_level=0! Is that a clue? Wieeeeeerd!
XML output:
From gcc 3.2:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization>
<b class_id="0" tracking_level="0" version="1"> <px class_id="2" class_name="derived" tracking_level="1" version="0" object_id="_0"> <base class_id="1" tracking_level="1" version="0" object_id="_1"></base> derived id </px> </b>From Visual C++ 7.1:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <!DOCTYPE boost_serialization>
<b class_id="0" tracking_level="0" version="1"> <px class_id="1" class_name="derived" tracking_level="1" version="0" object_id="_0"> <base class_id="2" tracking_level="0" version="0"></base> derived id </px> </b>
shared_ptr addresses are not tracked since one isn't serializing a pointer to a shared_ptr. So this is OK. What I see is that on the gcc output, we're "skipping" a class id. This is not what I expect to see. I looked into the code basic_oarchive.cpp where classes are tracked. I suspect this would be tracked down to something in the extended_type_info registry which isn't properly keeping track. Basically one would have to dive in with the debugger with your test. Robert Ramey
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: Wednesday, March 28, 2007 9:20 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users][serialization]Assertion`new_cid==cid'failed-fail s on gcc,works on msvc
Currently I only have the HEAD and RC_1_34 on my system and can't run a gcc test. I did build and compile and test with vc 7.1 and found no problems.
Try serializing your test to xml archive. That will make the details a lot more visible.
Thought you might like to know that the test I attached before works fine under gcc 3.4. Might need to put a note about gcc 3.2 somewhere? I still don't know what the real cause is. Thanks for your suggestions! Sohail
participants (2)
-
Robert Ramey
-
Sohail Somani