
A general comment on using this mailing list is to reply directly to the message, and to put the library in question in square brackets such as [serialization]. On 2/4/2013 9:29 PM, Adlai Shawareb wrote:
Thanks for your reply. Here is a code sample:
std::istringstream istr; <* put data into istr here *> boost::archive::text_iarchive ia(istr_);
Message* p_temp; ia & p_temp; mpBaseIncomingMessage = p_temp; // mpBaseIncomingMessage is of type (Message *)
mpIncomingMessage = static_cast
(mpBaseIncomingMessage); // mpIncomingMessage is a pointer to a class derived from Message mObjectCallbackMap.process(mpIncomingMessage->mEvent); // execute a callback for this event delete mpIncomingMessage; // delete the allocated memory We then see a crash on either the " mObjectCallbackMap.process..." line or the " delete mpIncomingMessage", but only when certain actions are taken by the system.
Any thoughts would be greatly appreciated.
Serialization library is designed to work with symmetrically serialized/de-serialized data. How are you serializing the Message*? You can save yourself lots of time by using boost::polymorphic_downcast in situations like your usage of static_cast above to ensure you actually have a base pointer pointing to the derived type you think you have. Also creating a standalone minimal example demonstrating the problem usually helps you detect where things have gone awry. Jeff