Serialization XML on windows and linux
Hi,
I've been using the boost serialization for quite a few projects and it works realy well in many different situations. But today I'm facing a problem, I find very difficult to solve. I serialize objects in a XML archive for a project working on linux and windows using boost 1.38. And oddly my files are not compatible between the two plateforms. When I try to deserialize an object saved on a different plateform, the application crashes despite the fact that I catch possible exceptions. When I compare the two files, it seems that I have a difference of class_id
Here is a sample of what I have on linux:
QUILLET Jean-Charles wrote:
Hi,
I've been using the boost serialization for quite a few projects and it works realy well in many different situations. But today I'm facing a problem, I find very difficult to solve. I serialize objects in a XML archive for a project working on linux and windows using boost 1.38. And oddly my files are not compatible between the two plateforms. When I try to deserialize an object saved on a different plateform, the application crashes despite the fact that I catch possible exceptions. When I compare the two files, it seems that I have a difference of class_id Here is a sample of what I have on linux:
<pNode class_id="6" class_name="Group" tracking_level="1" version="0" object_id="_1"> <Node class_id="5" tracking_level="1" version="0" object_id="_2"></Node> <noeuds class_id="7" tracking_level="0" version="0"> <count>0</count>
0 </noeuds> </pNode> .And the same object on windows:
<pNode class_id="6" class_name="Group" tracking_level="1" version="0" object_id="_1"> <Node class_id="7" tracking_level="1" version="0" object_id="_2"></Node> <noeuds class_id="8" tracking_level="0" version="0"> <count>0</count>
0 </noeuds> </pNode> .In my file on windows, I don't have any object of a class_id="5", weird.
Does any one know any reason for this behaviour ? Any idea greatly appreciated.
This is a new one. They should be absolutely compatible. Let us know when you find the source of this. Robert Ramey
-----Message d'origine----- De : Robert Ramey
<pNode class_id="6" class_name="Group" tracking_level="1" version="0" object_id="_1"> <Node class_id="5" tracking_level="1" version="0" object_id="_2"></Node> <noeuds class_id="7" tracking_level="0" version="0"> <count>0</count>
0 </noeuds> </pNode> .And the same object on windows:
<pNode class_id="6" class_name="Group" tracking_level="1" version="0" object_id="_1"> <Node class_id="7" tracking_level="1" version="0" object_id="_2"></Node> <noeuds class_id="8" tracking_level="0" version="0"> <count>0</count>
0 </noeuds> </pNode> .In my file on windows, I don't have any object of a class_id="5", weird.
Does any one know any reason for this behaviour ? Any idea greatly appreciated.
This is a new one. They should be absolutely compatible. Let us know when you find the source of this.
Robert Ramey
I might need some help to find out what's going on. At first, I need to understand how is incremented the "class_id". And in my windows file, I do not have any object of class_id="5". I think this might be the problem. Am I wrong ? Jean-Charles
-----Message d'origine----- De : Robert Ramey QUILLET Jean-Charles wrote:
Hi,
I've been using the boost serialization for quite a few projects and it works realy well in many different situations. But today I'm facing a problem, I find very difficult to solve. I serialize objects in a XML archive for a project working on linux and windows using boost 1.38. And oddly my files are not compatible between the two plateforms. When I try to deserialize an object saved on a different plateform, the application crashes despite the fact that I catch possible exceptions. When I compare the two files, it seems that I have a difference of class_id Here is a sample of what I have on linux:
<pNode class_id="6" class_name="Group" tracking_level="1" version="0" object_id="_1"> <Node class_id="5" tracking_level="1" version="0" object_id="_2"></Node> <noeuds class_id="7" tracking_level="0" version="0"> <count>0</count>
0 </noeuds> </pNode> .And the same object on windows:
<pNode class_id="6" class_name="Group" tracking_level="1" version="0" object_id="_1"> <Node class_id="7" tracking_level="1" version="0" object_id="_2"></Node> <noeuds class_id="8" tracking_level="0" version="0"> <count>0</count>
0 </noeuds> </pNode> .In my file on windows, I don't have any object of a class_id="5", weird.
Does any one know any reason for this behaviour ? Any idea greatly appreciated.
This is a new one. They should be absolutely compatible. Let us know when you find the source of this.
Robert Ramey
After a few investigations, it seems that my problem is related to the fact that I'm serializing polymorphic objects through a plugin system. I think the linux version should be the good one as no class_id is missing. It seems that there is something that might solve my problem in boost 1.4* reading this: http://www.boost.org/doc/libs/1_43_0/libs/serialization/doc/special.html#dll... I understand that I might have redundant serialization code in my application and in the shared librairies: one version might be called on windows and another one from linux (pure speculation) producing two versions of a serialized object. Does anyone have any experience with this ? Do I have a way out using boost 1.38 or should I upgrade to a newer version to take advantage of the BOOST_EXPORT_CLASS_IMPLEMENT macro ? Any idea most welcome, Jean-Charles
QUILLET Jean-Charles wrote:
-----Message d'origine-----
After a few investigations, it seems that my problem is related to the fact that I'm serializing polymorphic objects through a plugin system. I think the linux version should be the good one as no class_id is missing. It seems that there is something that might solve my problem in boost 1.4* reading this:
http://www.boost.org/doc/libs/1_43_0/libs/serialization/doc/special.html#dll...
I understand that I might have redundant serialization code in my application and in the shared librairies: one version might be called on windows and another one from linux (pure speculation) producing two versions of a serialized object.
Does anyone have any experience with this ?
This is a situation I have been concerned about. New versions of the library include code to address this. However, your code might invoke an assert trap rather than failing as it does now. My argument is that this is an improvement - not every one agrees however. My recommendation is a) upgrade to lastest boost released b) structure your code so that code is not repeated across DLLS Robert Ramey
participants (2)
-
QUILLET Jean-Charles
-
Robert Ramey