[Serialization] issue with portable_binary_oarchive
Hi,
I am trying to use the portable binary archive example.
I need to serialize only integers and strings.
I tried it on linux and solaris5.8. The result binary stream is not the
same and deserialization fails.
I used hex viewer and notice that the files are very similar except for
some few differences which results from endienness issues. Can it be
that the metadata is written differently on each platform.
This is happens when I serialize derived class through a pointer to base
class. (I used BOOS_CLASS_EXPORT)
Below you will find a test case. It produce differ output on linux and
solaris.
Am I missing something?
Thanks in advance
Dan Leibovich
#include <fstream>
#include "portable_binary_oarchive.hpp"
#include
We'll look into it. If you get any more information, feel free to share it.
Robert Ramey
"Dan Leibovich"
Hi Robert,
Were you able to find some clue?
I don't think it is related to the problem but there are some compilation warnings, do you have suggestion how to avoid it?
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member
function `void boost::archive::basic_binary_iarchive<Archive>::init() [with
Archive = portable_binary_iarchive]':
portable_binary_iarchive.hpp:116: instantiated from here
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing
`boost::archive::version_type::operator unsigned int&()' over `
boost::archive::version_type::operator const unsigned int&() const'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
for conversion from `boost::archive::version_type' to `unsigned int'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
because conversion sequence for the argument is better
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member
function `void boost::archive::basic_binary_iarchive<Archive>::init() [with
Archive = boost::archive::binary_iarchive]':
../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:51: instantiated from `void boost::archive::binary_iarchive_impl<Archive>::init() [with Archive = boost::archive::binary_iarchive]'
../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:66: instantiated from `boost::archive::binary_iarchive_impl<Archive>::binary_iarchive_impl(std::istream&, unsigned int) [with Archive = boost::archive::binary_iarchive]'
../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:80: instantiated from here
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing
`boost::archive::version_type::operator unsigned int&()' over `
boost::archive::version_type::operator const unsigned int&() const'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
for conversion from `boost::archive::version_type' to `unsigned int'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning:
because conversion sequence for the argument is better
Thank you
Dan
________________________________
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey
Sent: ד 21 פברואר 2007 21:54
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
We'll look into it. If you get any more information, feel free to share it.
Robert Ramey
"Dan Leibovich"
Sorry, I haven't looked into it.
Looking at ...basic_binary_archive I do see that the meta data - object id, etc
are converted to integer types so it looks like this issue was considered. So its not a super obvious issue. I do believe that by making a small test - serializing each of the meta data tag types, you might reveal which one - or more - are hanging things up. Try making a small test:
boost::archive::class_id cid = 100;
ar << cid;
ar << 324;
...
boost::archive::class_id cid
ar >> cid;
assert(100 == cide);
ar >> i;
assert(i == 324);
...
That would be helpful.
Robert Ramey
"Dan Leibovich"
Hi,
I have tried to create tests as you described.
I assume you meant boost::archive::class_id_type
I tried it also with class_id_optional_type, class_id_reference_type, object_id_type, object_reference_type, version_type, tracking_type . Are there any others I should check ?
I guess I did not understand your request since almost all tests failed (also with text archive)
For example the following simple test fails:
#include
I ran your example and made it fail on my machine.
I traced this to an asymetry in the serialization of class_id_optional. I can fix this - but
I don't think its the cause of any other problems. I changed your program to
use class_id rather than class_id_optional and it passed fine. I also ran it with
object_id_type and no problems. I'm not sure what to suggest now.
Robert Ramey
"Dan Leibovich"
Hi Robert,
I think I found a clue.
The following simple program produce deferent binary dump on linux and solaris.
#include "portable_binary_iarchive.hpp"
#include "portable_binary_oarchive.hpp"
#include <fstream>
int main () {
char* file = "file" ;
boost::archive::class_id_type cid ;
std::ofstream ofs(file) ;
portable_binary_oarchive oar(ofs) ;
oar << cid ;
ofs.close();
}
The output:
linux: 65 00 00 00
solaris: 00 00 00 65
I set a break point on save_impl() in portable_binary_archive.hpp and notice that the program never get to this method. The data is saved using the default template method which calls to :
boost::archive::binary_oarchive_impl
When I make the following change it works
"Dan Leibovich"
What change ? I can't find
Thanks
Dan
________________________________
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey
Sent: ד 28 פברואר 2007 00:40
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
When I make the following change it works
"Dan Leibovich"
Hi,
I just found this "const",
I tried it but still the program never get to the save_impl() method, hence the output not portable.
Thanks
Dan
p.s : I missed the initialization in the code when I copied it. It should be: boost::archive::class_id_type const cid (100) ;
________________________________
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey
Sent: ד 28 פברואר 2007 00:40
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
When I make the following change it works
"Dan Leibovich"
OK - I've looked at this a little more carefully.
First - on my VC 7.1 compiler I find that the portable_binary_oarchive.hpp
line #85
template<class T>
void save(const T & t){
this->primitive_base_t::save(t);
}
void save(const unsigned int t){
save_impl(t);
}
void save(const int t){
save_impl(t);
}
void save(const unsigned long t){
save_impl(t);
}
void save(const long t){
save_impl(t);
}
and the type in question is "short". It seems that on this compiler at
least - and it looks like others
"short" is its own type so it doesn't match any of the specializations. So
I guess we should add the following:
void save(const short t){
save_impl(t);
}
void save(const unsigned short t){
save_impl(t);
}
and correspondingly for ....iarchive.hpp.
Also you might consider replacing
// default fall through for any types not specified here
template<class T>
void save(const T & t){
this->primitive_base_t::save(t);
}
with
template<class T>
void save(const T & t){
BOOST_STATIC_ASSERT( some type false here);
}
void save(const unsigned char t){
this->primitive_base_t::save(t);
}
... same for all char/wchar_t types.
which would guarentee no future surprises. or that all future surprises
occur
sooner rather than later.
Finally, This has made me look at
basic_binary_oarchive.hpp and I'm inclined to replace
template<class T>
void save_override(T & t, BOOST_PFTO int){
this->save_override(const_cast<const T>(t), 0);
}
with
template<class T>
void save_override(const T & t, BOOST_PFTO int){
this->array_oarchive::save_override(t, 0);
}
... same for load. I'll do this on my own system but won't check it in
until
I get a chance to run some tests here. You might want to experiment with
this.
Robert Ramey
"Dan Leibovich"
Hi,
I have added the specializations methods for short and now the serialization output is the same for both platforms (linux and solaris).
But when I try to load the dump file, the program received seg fault signal
in boost::archive::detail::basic_iarchive_impl::load_pointer()
on: bpis_ptr->load_object_ptr(ar, t, co.file_version);
I will be happy to try any changes you suggest.
I have noticed (according to your code change suggestions) that I do not have the latest version of the lib.
I downloaded boost 1.33.1 , should I download newer version and if so how can I do it?
Thanks
Dan Leibovich
-----Original Message-----
From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey
Sent: ד 28 פברואר 2007 18:24
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
OK - I've looked at this a little more carefully.
First - on my VC 7.1 compiler I find that the portable_binary_oarchive.hpp line #85
template<class T>
void save(const T & t){
this->primitive_base_t::save(t);
}
void save(const unsigned int t){
save_impl(t);
}
void save(const int t){
save_impl(t);
}
void save(const unsigned long t){
save_impl(t);
}
void save(const long t){
save_impl(t);
}
and the type in question is "short". It seems that on this compiler at least - and it looks like others "short" is its own type so it doesn't match any of the specializations. So I guess we should add the following:
void save(const short t){
save_impl(t);
}
void save(const unsigned short t){
save_impl(t);
}
and correspondingly for ....iarchive.hpp.
Also you might consider replacing
// default fall through for any types not specified here template<class T> void save(const T & t){
this->primitive_base_t::save(t);
}
with
template<class T>
void save(const T & t){
BOOST_STATIC_ASSERT( some type false here); }
void save(const unsigned char t){
this->primitive_base_t::save(t); } ... same for all char/wchar_t types.
which would guarentee no future surprises. or that all future surprises occur sooner rather than later.
Finally, This has made me look at
basic_binary_oarchive.hpp and I'm inclined to replace
template<class T>
void save_override(T & t, BOOST_PFTO int){
this->save_override(const_cast<const T>(t), 0);
}
with
template<class T>
void save_override(const T & t, BOOST_PFTO int){
this->array_oarchive::save_override(t, 0);
}
... same for load. I'll do this on my own system but won't check it in
until
I get a chance to run some tests here. You might want to experiment with
this.
Robert Ramey
"Dan Leibovich"
Hmm- that would seem to suggest that bpis_ptr is NULL or something. I would guess that browsing the stack trace with the debugger might shed light here. It that doesn't resolve the issue, make a small program that illustrates the problem so I can run it here. Note that in my previous email, I suggested a change in the one of the libraries headers involving loading and const. It turns out that this change isn't appropriate. I presume you found that as it fails to compile. I don't think this issue would be affected by moving to a later version. Robert Ramey Dan Leibovich wrote:
Hi,
I have added the specializations methods for short and now the serialization output is the same for both platforms (linux and solaris).
But when I try to load the dump file, the program received seg fault signal in boost::archive::detail::basic_iarchive_impl::load_pointer() on: bpis_ptr->load_object_ptr(ar, t, co.file_version);
I will be happy to try any changes you suggest.
I have noticed (according to your code change suggestions) that I do not have the latest version of the lib. I downloaded boost 1.33.1 , should I download newer version and if so how can I do it?
Thanks Dan Leibovich
Hi again,
I was able to create a minimal test case to reproduce the problem.
I found that the problem occurs when a class includes a pointer to the same type as the class.
I added the following to portable_binary_oarchive.hpp
void save(const unsigned short t){
save_impl(t);
}
void save(const short t){
save_impl(t);
}
and to portable_binary_iarchive.hpp
void load(unsigned short & t){
long l;
load_impl(l, sizeof(unsigned short));
t = l;
}
void load(short & t){
long l;
load_impl(l, sizeof(short));
t = l;
}
The program below fails on asserts:
When the class has virtual method:
boost/archive/basic_binary_iprimitive.hpp:112: void boost::archive::basic_binary_iprimitive
Hi,
I have added the specializations methods for short and now the serialization output is the same for both platforms (linux and solaris).
But when I try to load the dump file, the program received seg fault signal in boost::archive::detail::basic_iarchive_impl::load_pointer() on: bpis_ptr->load_object_ptr(ar, t, co.file_version);
I will be happy to try any changes you suggest.
I have noticed (according to your code change suggestions) that I do not have the latest version of the lib. I downloaded boost 1.33.1 , should I download newer version and if so how can I do it?
Thanks Dan Leibovich
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
For starters, you should use ios::binary flag on the files. But still I have a problem with this - I'm looking into it. Robert Ramey Dan Leibovich wrote:
Hi again,
I was able to create a minimal test case to reproduce the problem. I found that the problem occurs when a class includes a pointer to the same type as the class.
I added the following to portable_binary_oarchive.hpp void save(const unsigned short t){ save_impl(t); } void save(const short t){ save_impl(t); }
and to portable_binary_iarchive.hpp void load(unsigned short & t){ long l; load_impl(l, sizeof(unsigned short)); t = l; } void load(short & t){ long l; load_impl(l, sizeof(short)); t = l; }
The program below fails on asserts: When the class has virtual method:
boost/archive/basic_binary_iprimitive.hpp:112: void boost::archive::basic_binary_iprimitive
::load_binary(void*, unsigned int) [with Archive = portable_binary_iarchive, IStream = std::basic_istream ]: Assertion `static_caststd::size_t((std::numeric_limitsstd::streamsize::max)()) = count' failed.
otherwise:
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.
The program:
#include
#include "portable_binary_oarchive.hpp" #include "portable_binary_iarchive.hpp" #include <fstream> class A { public: int x; A* a ;
template<class Archive> void serialize (Archive & ar, const unsigned int version) { ar & x ; ar & a ; }
A() {} A(int x_) : x(x_), a(0) {} virtual void foo() {} ; // if removed - another kind of assert };
int main() { char* file = "file" ; std::ofstream ofs(file) ; portable_binary_oarchive oar(ofs) ; const A a(1);
oar << a ;
ofs.close() ;
A aa ;
std::ifstream ifs(file) ; portable_binary_iarchive iar(ifs) ; iar >> aa ; }
Thanks, Dan Leibovich
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: ã 28 ôáøåàø 2007 22:05 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
Hmm- that would seem to suggest that bpis_ptr is NULL or something.
I would guess that browsing the stack trace with the debugger might shed light here. It that doesn't resolve the issue, make a small program that illustrates the problem so I can run it here.
Note that in my previous email, I suggested a change in the one of the libraries headers involving loading and const. It turns out that this change isn't appropriate. I presume you found that as it fails to compile.
I don't think this issue would be affected by moving to a later version.
Robert Ramey
Dan Leibovich wrote:
Hi,
I have added the specializations methods for short and now the serialization output is the same for both platforms (linux and solaris).
But when I try to load the dump file, the program received seg fault signal in boost::archive::detail::basic_iarchive_impl::load_pointer() on: bpis_ptr->load_object_ptr(ar, t, co.file_version);
I will be happy to try any changes you suggest.
I have noticed (according to your code change suggestions) that I do not have the latest version of the lib. I downloaded boost 1.33.1 , should I download newer version and if so how can I do it?
Thanks Dan Leibovich
_______________________________________________ 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
Hi Robert, Were you able to find the source of this failure ? Thanks Dan Leibovich -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: ו 02 מרץ 2007 02:47 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive For starters, you should use ios::binary flag on the files. But still I have a problem with this - I'm looking into it. Robert Ramey Dan Leibovich wrote:
Hi again,
I was able to create a minimal test case to reproduce the problem. I found that the problem occurs when a class includes a pointer to the same type as the class.
I added the following to portable_binary_oarchive.hpp void save(const unsigned short t){ save_impl(t); } void save(const short t){ save_impl(t); }
and to portable_binary_iarchive.hpp void load(unsigned short & t){ long l; load_impl(l, sizeof(unsigned short)); t = l; } void load(short & t){ long l; load_impl(l, sizeof(short)); t = l; }
The program below fails on asserts: When the class has virtual method:
boost/archive/basic_binary_iprimitive.hpp:112: void boost::archive::basic_binary_iprimitive
::load_binary(void*, unsigned int) [with Archive = portable_binary_iarchive, IStream = std::basic_istream ]: Assertion `static_caststd::size_t((std::numeric_limitsstd::streamsize::max)( )) = count' failed.
otherwise:
basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archi ve::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.
The program:
#include
#include "portable_binary_oarchive.hpp" #include "portable_binary_iarchive.hpp" #include <fstream> class A { public: int x; A* a ;
template<class Archive> void serialize (Archive & ar, const unsigned int version) { ar & x ; ar & a ; }
A() {} A(int x_) : x(x_), a(0) {} virtual void foo() {} ; // if removed - another kind of assert };
int main() { char* file = "file" ; std::ofstream ofs(file) ; portable_binary_oarchive oar(ofs) ; const A a(1);
oar << a ;
ofs.close() ;
A aa ;
std::ifstream ifs(file) ; portable_binary_iarchive iar(ifs) ; iar >> aa ; }
Thanks, Dan Leibovich
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: ã 28 ôáøåàø 2007 22:05 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
Hmm- that would seem to suggest that bpis_ptr is NULL or something.
I would guess that browsing the stack trace with the debugger might shed light here. It that doesn't resolve the issue, make a small program that illustrates the problem so I can run it here.
Note that in my previous email, I suggested a change in the one of the libraries headers involving loading and const. It turns out that this change isn't appropriate. I presume you found that as it fails to compile.
I don't think this issue would be affected by moving to a later version.
Robert Ramey
Dan Leibovich wrote:
Hi,
I have added the specializations methods for short and now the serialization output is the same for both platforms (linux and solaris).
But when I try to load the dump file, the program received seg fault signal in boost::archive::detail::basic_iarchive_impl::load_pointer() on: bpis_ptr->load_object_ptr(ar, t, co.file_version);
I will be happy to try any changes you suggest.
I have noticed (according to your code change suggestions) that I do not have the latest version of the lib. I downloaded boost 1.33.1 , should I download newer version and if so how can I do it?
Thanks Dan Leibovich
_______________________________________________ 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
Hi, Do you have any update? I will really appreciate any direction on how to proceed. Thanks Dan -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: ו 02 מרץ 2007 02:47 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive For starters, you should use ios::binary flag on the files. But still I have a problem with this - I'm looking into it. Robert Ramey Dan Leibovich wrote:
Hi again,
I was able to create a minimal test case to reproduce the problem. I found that the problem occurs when a class includes a pointer to the same type as the class.
I added the following to portable_binary_oarchive.hpp void save(const unsigned short t){ save_impl(t); } void save(const short t){ save_impl(t); }
and to portable_binary_iarchive.hpp void load(unsigned short & t){ long l; load_impl(l, sizeof(unsigned short)); t = l; } void load(short & t){ long l; load_impl(l, sizeof(short)); t = l; }
The program below fails on asserts: When the class has virtual method:
boost/archive/basic_binary_iprimitive.hpp:112: void boost::archive::basic_binary_iprimitive
::load_binary(void*, unsigned int) [with Archive = portable_binary_iarchive, IStream = std::basic_istream ]: Assertion `static_caststd::size_t((std::numeric_limitsstd::streamsize::max)( )) = count' failed.
otherwise:
basic_iarchive.cpp:466: const boost::archive::detail::basic_pointer_iserializer* boost::archive::detail::basic_iarchive_impl::load_pointer(boost::archi ve::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.
The program:
#include
#include "portable_binary_oarchive.hpp" #include "portable_binary_iarchive.hpp" #include <fstream> class A { public: int x; A* a ;
template<class Archive> void serialize (Archive & ar, const unsigned int version) { ar & x ; ar & a ; }
A() {} A(int x_) : x(x_), a(0) {} virtual void foo() {} ; // if removed - another kind of assert };
int main() { char* file = "file" ; std::ofstream ofs(file) ; portable_binary_oarchive oar(ofs) ; const A a(1);
oar << a ;
ofs.close() ;
A aa ;
std::ifstream ifs(file) ; portable_binary_iarchive iar(ifs) ; iar >> aa ; }
Thanks, Dan Leibovich
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: ã 28 ôáøåàø 2007 22:05 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
Hmm- that would seem to suggest that bpis_ptr is NULL or something.
I would guess that browsing the stack trace with the debugger might shed light here. It that doesn't resolve the issue, make a small program that illustrates the problem so I can run it here.
Note that in my previous email, I suggested a change in the one of the libraries headers involving loading and const. It turns out that this change isn't appropriate. I presume you found that as it fails to compile.
I don't think this issue would be affected by moving to a later version.
Robert Ramey
Dan Leibovich wrote:
Hi,
I have added the specializations methods for short and now the serialization output is the same for both platforms (linux and solaris).
But when I try to load the dump file, the program received seg fault signal in boost::archive::detail::basic_iarchive_impl::load_pointer() on: bpis_ptr->load_object_ptr(ar, t, co.file_version);
I will be happy to try any changes you suggest.
I have noticed (according to your code change suggestions) that I do not have the latest version of the lib. I downloaded boost 1.33.1 , should I download newer version and if so how can I do it?
Thanks Dan Leibovich
_______________________________________________ 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
Dan Leibovich wrote:
Hi,
Do you have any update? I will really appreciate any direction on how to proceed.
Thanks Dan
I did spend a little time with it. I'm not sure what's missing
but here is my current test. I did make pass by
avoiding usage of a 0 valued pointer. So this
suggests that there someing amiss with the
serialization of such pointers in this demo.
I'm quite confident this is an issue with
this particular archive demo as the test
suite explicitly tests for this.
Robert Ramey
#include
Hi, I have switched all the 0 pointer cases to use some Null object. Now everything works fine. Thanks very much for your help. One last (I hope) question: The compilation of this archive produce some compilation warnings, how can I avoid it ? Thanks again, Dan Leibovich ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member function `void boost::archive::basic_binary_iarchive<Archive>::init() [with Archive = portable_binary_iarchive]': portable_binary_iarchive.hpp:116: instantiated from here ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing `boost::archive::version_type::operator unsigned int&()' over ` boost::archive::version_type::operator const unsigned int&() const' ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: for conversion from `boost::archive::version_type' to `unsigned int' ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: because conversion sequence for the argument is better ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member function `void boost::archive::basic_binary_iarchive<Archive>::init() [with Archive = boost::archive::binary_iarchive]': ../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:51: instantiated from `void boost::archive::binary_iarchive_impl<Archive>::init() [with Archive = boost::archive::binary_iarchive]' ../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:66: instantiated from `boost::archive::binary_iarchive_impl<Archive>::binary_iarchive_impl(std::istream&, unsigned int) [with Archive = boost::archive::binary_iarchive]' ../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:80: instantiated from here ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing `boost::archive::version_type::operator unsigned int&()' over ` boost::archive::version_type::operator const unsigned int&() const' ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: for conversion from `boost::archive::version_type' to `unsigned int' ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: because conversion sequence for the argument is better -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: ב 12 מרץ 2007 22:34 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive Dan Leibovich wrote:
Hi,
Do you have any update? I will really appreciate any direction on how to proceed.
Thanks Dan
I did spend a little time with it. I'm not sure what's missing but here is my current test. I did make pass by avoiding usage of a 0 valued pointer. So this suggests that there someing amiss with the serialization of such pointers in this demo.
I'm quite confident this is an issue with this particular archive demo as the test suite explicitly tests for this.
Robert Ramey
#include
Dan Leibovich wrote:
Hi, I have switched all the 0 pointer cases to use some Null object. Now everything works fine.
Your situation highlights a bug somewhere and I'm still concerned about this. I am getting closer to this. Its a bug in portable_archive demo related to sign extension for certain negative values. This has cropped up in the case of storing a negative char value which is class_id. I'm not sure that this doesn't come up with other cases so you might be a little careful in using portable binary archive.
Thanks very much for your help.
and for yours.
One last (I hope) question:
The compilation of this archive produce some compilation warnings, how can I avoid it ?
I'm not getting this with my vc 7.1 compiler using the HEAD so I guess they've been addressed. You might also double check the recent changes I've made in the HEAD made to binary archives based on your case. Robert Ramey
Thanks again, Dan Leibovich
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member function `void boost::archive::basic_binary_iarchive<Archive>::init() [with Archive = portable_binary_iarchive]': portable_binary_iarchive.hpp:116: instantiated from here ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing `boost::archive::version_type::operator unsigned int&()' over ` boost::archive::version_type::operator const unsigned int&() const'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: for conversion from `boost::archive::version_type' to `unsigned int'
../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: because conversion sequence for the argument is better ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp: In member function `void boost::archive::basic_binary_iarchive<Archive>::init() [with Archive = boost::archive::binary_iarchive]': ../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:51: instantiated from `void boost::archive::binary_iarchive_impl<Archive>::init() [with Archive = boost::archive::binary_iarchive]' ../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:66: instantiated from `boost::archive::binary_iarchive_impl<Archive>::binary_iarchive_impl(std::istream&, unsigned int) [with Archive = boost::archive::binary_iarchive]' ../boost/boost_1_33_1/boost/archive/binary_iarchive.hpp:80: instantiated from here ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: choosing `boost::archive::version_type::operator unsigned int&()' over ` boost::archive::version_type::operator const unsigned int&() const' ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: for conversion from `boost::archive::version_type' to `unsigned int' ../boost/boost_1_33_1/boost/archive/impl/basic_binary_iarchive.ipp:67: warning: because conversion sequence for the argument is better
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Robert Ramey Sent: á 12 îøõ 2007 22:34 To: boost-users@lists.boost.org Subject: Re: [Boost-users] [Serialization] issue withportable_binary_oarchive
Dan Leibovich wrote:
Hi,
Do you have any update? I will really appreciate any direction on how to proceed.
Thanks Dan
I did spend a little time with it. I'm not sure what's missing but here is my current test. I did make pass by avoiding usage of a 0 valued pointer. So this suggests that there someing amiss with the serialization of such pointers in this demo.
I'm quite confident this is an issue with this particular archive demo as the test suite explicitly tests for this.
Robert Ramey
#include
#include
#include <fstream>
class A {
public:
int x;
A* a ;
template<class Archive>
void serialize (Archive & ar, const unsigned int version) {
ar & x ;
ar & a ;
};
A() {}
A(int x_) : x(x_), a(0) {} // this fails
//A(int x_) : x(x_), a(this) {} // this works
virtual void foo() {} ; // if removed - another kind of assert };
};
int main() {
char* file = "c:\\temp\\file" ;
std::ofstream ofs(file, std::ios::binary) ;
portable_binary_oarchive oar(ofs) ;
const A a(1);
oar << a ;
ofs.close() ;
A aa ;
std::ifstream ifs(file, std::ios::binary) ;
portable_binary_iarchive iar(ifs) ;
iar >> aa ;
}
_______________________________________________ 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
participants (2)
-
Dan Leibovich
-
Robert Ramey