|
Boost Users : |
From: Dan Leibovich (dan_at_[hidden])
Date: 2007-03-12 12:14:50
Hi,
Do you have any update?
I will really appreciate any direction on how to proceed.
Thanks
Dan
-----Original Message-----
From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert Ramey
Sent: × 02 ×רץ 2007 02:47
To: boost-users_at_[hidden]
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<Archive,
> IStream>::load_binary(void*, unsigned int) [with Archive =
> portable_binary_iarchive, IStream = std::basic_istream<char,
> std::char_traits<char> >]: Assertion
> `static_cast<std::size_t>((std::numeric_limits<std::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 <boost/serialization/access.hpp> #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_at_[hidden]
> [mailto:boost-users-bounces_at_[hidden]] On Behalf Of Robert Ramey
> Sent: ã 28 ôáøåà ø 2007 22:05
> To: boost-users_at_[hidden]
> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net