Re: [Boost-users] Serialization: crash at launch ofprogram(duetoboost::serialization::base_object)
Ok, I will try to send a small example to the list tomorrow. In fact I think everything lies in the fact that using boost::serialization::base_object also registers the fact that the classes are parent and child. The serialization system needs to know that in order to make casts later. Somehow it probably does not like it when it tries to register several different classes as the parent of the same class. Jean-Noël -----Message d'origine----- De : boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] De la part de Robert Ramey Envoyé : jeudi 6 avril 2006 17:20 À : boost-users@lists.boost.org Objet : Re: [Boost-users] Serialization: crash at launch ofprogram(duetoboost::serialization::base_object) I would be wiling to look at a small example which demonstrates the problem. Robert Ramey RIVASSEAU Jean Noel wrote:
I have tried to use versioning. Exact same problem.
More explanations: if I use the version facility, and at load I switch the boost::serialization::base_object<MyBaseClass> depending on the version, the same crash will happen.
Eg: this code:
if (version == 0) { boost::serialization::base_object
} Else { boost::serialization::base_object } Will cause the same crash.
So, could you look at the code, because currently there is no way to change the base class of an object appearing in serialized archives, if you want to be able to read old archives.
It seems like there is a bug, if the base_object is used several times with different classes, the crash will appear.
Thanks
Jean-Noël
-----Message d'origine----- De : boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] De la part de Robert Ramey Envoyé : mercredi 5 avril 2006 17:15 À : boost-users@lists.boost.org Objet : Re: [Boost-users] Serialization: crash at launch of program (duetoboost::serialization::base_object)
The "version" facility is provided for maintaining the ability to read old archives. It doesn't sound like you're using this and its sounds like you should be.
Robert Ramey
"RIVASSEAU Jean Noel"
wrote in message news:87F60F7FA02FF749AFB02BD9FCAA6B0401074928@naserv31.nanterre.oberthurcs.com... Hello, My program crashes at launch (not even a exit(0) as the first line of main(int argc, char *argv[]) will stop it from crashing), due to the BSL.
What I am trying to do is: I have a class, whose serialization is split (eg, save and load functions are provided, and they are different). Now this class had a parent class, so I used to call boost::serialization::base_object<MObject>() on the base class MObject.
However I want to change the parent of my class to a different class. I also want to update my old archives, so I decided to leave the load function of my class untouched, while I would change the save function, to update the call to base_object to the new parent class (not MObject anymore). I thought it would work, since it would load the old archive using the same method, but save it using the new, so I would have ran only one time the program and the archive would be updated (then, of course, before running it again I would have to recompile it one more time with the correct changes to the load function).
But it does not work as expected, since it seems the BSL does not like the fact that save and load functions calls to boost::serialization::base_object do not specify the same base class. It does not complain at compile time but crashes at run time before even entering main and certainly before loading any archive. The crash is due to a NULL pointer, I have tried to debug with gdb but the crash apparently occurs on the _libkernel32_a_iname () so I do not not know where it is (too low level for me).
Robert, do you have an idea what is going on? I suspect a bug - however if it is "normal" behaviour (I think it should then throw an exception rather than crash),
*** Tell that to the author of _libkernel32_a_iname ()
do you have an idea how could I update my archives? I need to change the parent of this class, but need to be able to read my old archives - and changing them "by hand" by looking into the XML archive code is tool hard.
Thank you, regards
Jean-Noël Rivasseau
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users =
Note that there is a test test_..._mi which tests serialization with classes which have multiple parents. So I would hope that this wouldn't be a problem. But you never know Robert Ramey RIVASSEAU Jean Noel wrote:
Ok, I will try to send a small example to the list tomorrow. In fact I think everything lies in the fact that using boost::serialization::base_object also registers the fact that the classes are parent and child. The serialization system needs to know that in order to make casts later.
Somehow it probably does not like it when it tries to register several different classes as the parent of the same class.
Jean-Noël
Robert Ramey wrote:
RIVASSEAU Jean Noel wrote:
Ok, I will try to send a small example to the list tomorrow. In fact I think everything lies in the fact that using boost::serialization::base_object also registers the fact that the classes are parent and child. The serialization system needs to know that in order to make casts later.
Somehow it probably does not like it when it tries to register several different classes as the parent of the same class.
Note that there is a test test_..._mi which tests serialization with classes which have multiple parents. So I would hope that this wouldn't be a problem. But you never know
Robert, the problem Jean is having is not related to multiple inheritance.
The problem above is best described:
class version 1:
================
struct base_old{ ... };
struct derived : base_old { ... };
class version 2:
================
struct base_new{ ... };
struct derived : base_new { ... };
What would the serialize or save/load function look like to support archives
containing version 1? I'd assume something along the lines of:
template<class Archive>
void serialize(Archive & ar, const unsigned int version)
{
if( version == 2)
{
ar & boost::serialization::base_object
participants (3)
-
Jeff Flinn
-
RIVASSEAU Jean Noel
-
Robert Ramey