Boost Users :
Subject: [Boost-users] Serialization / "Pointer conflict"
From: Dan Eaton (daniel.eaton_at_[hidden])
Date: 2009-05-14 18:16:12
Sorry for my last question; it was posted hastily -- I subsequently found the Reference->Special Considerations->Optimizations section.
Anyway, I have a new problem/question:
It's somewhat similar to the "pointer_conflict" example:
void save(T t)
// create stream & output archive "oar"
ar << t;
// send with mpi/asio
// retrieve string with mpi/asio
// create stream & input archive "iar"
iar >> tmp;
My problem (a few hours of debugging) was that on one end, I was passing in a pointer to an object:
and on the deserialization end, I was requesting an object:
FooClass foo = load<FooClass>();
My mistake only showed up through the "array_size_too_short", since as part of the deserialization of FooClass, a fixed-length array was being deserialized, and I guess wonky parsing resulted in "count" being larger than "current_count" in iserializer.hpp.
Is what I was doing dangerous, or should/can the boost::serialization library somehow catch that mistake (i.e. in the serialized string, cant it not detect that the object is a pointer to an object, even if it's unregistered)?
My fix is to disallow the serialization of pointers on the forward side:
if( boost::is_pointer<T> )
Thanks in advance for any thoughts you might share on the matter,
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