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