Problems with De/Serializing data structures with dll

Hi,
I'm quite noob with boost and I wrote a little test program to test how
boost handles serialization of data structures and deserializing the data in
dll-plug-in. ( In this case only linked list of BaseImplementation objects,
but if I got everything OK more complex structures is need to be
serialized).
It seems that I have(surprisingly) some problems with de/serializing list
properly maybe cause of m_next pointers. I've read the documentation, but
not have found help for this issue.
Here's some relevant parts of my code ( I know It's a bit ugly, but hey!
It's only for test purposes :) :
Base.h:
/* Abstract base class declaration of objects in linked list*/
#ifndef BASE_H
#define BASE_H
#include <string>
#include <iostream>
#include

cute example.
This has nothing to do with dlls etc. The problem is actually quite simple:
//The serialization itself
oa.register_type(static_cast

Robert Ramey wrote:
This has nothing to do with dlls etc. The problem is actually quite simple: ...
a) Your data structure is a loooong linked list of pointers. b) Serialization of the first pointer in the list is going to recursively serialize all the objects in the list. c) subsequent serialization of any previously serialized ones will be optimized away.
If you want to do this in this way, The obvious way would be to make sure there's enough stack space. Remember that serialization is a recurrsive process. If you really need to serialize an arbitrarily long linked list, you'll have to think of another way. You might want to look at the implementation of serialization for std::list in the library which serializes the data but reconstructs the links on load (using push back) rather than serializating them. This was done not to avoid this problem but rather because it made use of the public interface of std::list.
Robert Ramey
P.S. Usage of export often cause "weird linking errors" do to the need to explicitly instantiate code not referred to by name. One then has to invest some effort in thinking about getting stuff serialized. This conflicts with the goal of the library to permit usage of serialization by those who have a lot of other stuff to do.
RR.
Thanks for your reply Robert! I thought a while the problem could be call stack(as the error message says :), but actually couldn't believe it will get full with 114 cells(with this platform). The reason I mentioned dlls was that I thought the problem could something to do with memory management of dlls( I'm quite noob with dlls also). But as I mentioned before linked list is not the issue in this. I used it as a simple test code. The purpose is to use the de/serialization to save/load the data content of our software and list(neither any other stl-container) is not suitable for this purpose. It is more tree-like structure which doesn't fit in easily in stl-containers. The amount of data can be really large and some meta data is needed if we use the solution which saves only the nodes/leafs of the tree and while loading set the cell's pointers right. Reconstruction will be difficult with meta data also. So it seems that the only solution to do the boost::de/serialization of large/huge self-made data structures easily is increase the size of call stack? Ps: Sorry about the "weird linking errors". I thought export could help me with this one and tried to give a hint I've also tried export. -- View this message in context: http://www.nabble.com/Problems-with-De-Serializing-data-structures-with-dll-... Sent from the Boost - Users mailing list archive at Nabble.com.

As I said - two solutions a) real simple - just increase the call stack. But this would mean that there might be problems with structures with indirection which goes too deep. b) use a system similar to the serialization of std::list which serializes only the data but rebuilds the links when the data is loaded. Robert Ramey Grimm wrote:
Robert Ramey wrote:
This has nothing to do with dlls etc. The problem is actually quite simple: ...
a) Your data structure is a loooong linked list of pointers. b) Serialization of the first pointer in the list is going to recursively serialize all the objects in the list. c) subsequent serialization of any previously serialized ones will be optimized away.
If you want to do this in this way, The obvious way would be to make sure there's enough stack space. Remember that serialization is a recurrsive process. If you really need to serialize an arbitrarily long linked list, you'll have to think of another way. You might want to look at the implementation of serialization for std::list in the library which serializes the data but reconstructs the links on load (using push back) rather than serializating them. This was done not to avoid this problem but rather because it made use of the public interface of std::list.
Robert Ramey
P.S. Usage of export often cause "weird linking errors" do to the need to explicitly instantiate code not referred to by name. One then has to invest some effort in thinking about getting stuff serialized. This conflicts with the goal of the library to permit usage of serialization by those who have a lot of other stuff to do.
RR.
Thanks for your reply Robert!
I thought a while the problem could be call stack(as the error message says :), but actually couldn't believe it will get full with 114 cells(with this platform). The reason I mentioned dlls was that I thought the problem could something to do with memory management of dlls( I'm quite noob with dlls also).
But as I mentioned before linked list is not the issue in this. I used it as a simple test code.
The purpose is to use the de/serialization to save/load the data content of our software and list(neither any other stl-container) is not suitable for this purpose. It is more tree-like structure which doesn't fit in easily in stl-containers. The amount of data can be really large and some meta data is needed if we use the solution which saves only the nodes/leafs of the tree and while loading set the cell's pointers right. Reconstruction will be difficult with meta data also.
So it seems that the only solution to do the boost::de/serialization of large/huge self-made data structures easily is increase the size of call stack?
Ps: Sorry about the "weird linking errors". I thought export could help me with this one and tried to give a hint I've also tried export.
participants (2)
-
Grimm
-
Robert Ramey