Boost logo

Boost Users :

From: Ivan (ivanr_at_[hidden])
Date: 2006-08-08 16:30:53


I'm running into what appears to be a bug in the serialization library, but maybe it is just a limitation on the
library's usage. I'm not getting any exceptions thrown during serialization/deserialization, but I'm getting corrupted
pointers after deserialiation.

I'm trying to serialize/deserialize an object that contains a vector of objects containing vectors (something like
below):

class TObject
{
  int x;
}

class TObjectContainer
{
  std::vector<TObject> ObjectVector;
};

class TRoot
{
  std::vector<TObjectContainer> ObjectContainerVector;
  std::vector <TObject*> ObjectPtrVector;
};

In simple cases, serializing/deserializing a structure like the above "appears" to work, but I believe the
deserialization code has a bug or two.

I think one bug is that the i index used to update the object_id_vectors in the reset_object_address is doubly
incremented, which seems wrong at first glance (once in for-loop, then again at bottom of for-loop, basic_iarchive.cpp,
lines 276 and 297).

The other bug appears to be in the way moveable_objects_recent and moveable_objects_end are being set prior to calling
reset_object_address. My assumption is the intent here is to modify the addresses of "trackable" sub-objects contained
within the vector element being moved, so that ptrs will be hooked back up correctly, but the moveable ptrs are being
set up in such a way that the vector elements (TObject) of the sub-vector (ObjectVector) are getting their addresses
modified when the stack version of TObjectContainer is copied to the vector. This seems wrong, because the TObjects are
allocated on the heap, so their addresses should not be updated in the object_vector_id table when the ObjectVector is
copied. The end result is that I'm getting bad pointers to the TObjects after deserialization.

best regards,

Dan Notestein


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