A couple of observations: a) you might try using xml_?archives for debugging. The consume more space are are easier to interpret. b) Could it be that you are doing something like: ar << lm ; // pointer to LogMessage ... ar >> m; // pointer to Message If so - this would be a problem. If you want to load(de-serialize) through a base class pointer, you have to save(serialize) also through a base class pointer. If this doesn't help, make a small test which just serializes and de-serializes and we can take a look at it. Robert Ramey sadrok wrote:
My application saves message classes derived from a Message base class (it has a virtual deconstructor) and sends this serialized data over a UNIX socket for IPC between interconnected processes. The sending side seems to work fine as can be seen from the debugging output below:
In base/module.cpp line 111 function SendMessage : [ 22 serialization::archive 3 4 core 10 LogMessage -1209954316 1 18 Sadrok::LogMessage 1 0 0 0 1168098092 55 Loaded module log from file modules/liblog.so pid 14250 ]
However on the receiving side I have this: ia & BOOST_SERIALIZATION_NVP(msginfo.msg); which ends up throwing an bad_cast exception Unhandled exception: St8bad_cast
msginfo.msg is Message* I even tried loading into a LogMessage * with the same error.
I have (in the logmessage header) BOOST_CLASS_EXPORT for the LogMessage (otherwise Boost would've thrown unregistered_class while saving).