serialization of a complex object

Dear list, I have tried many ways but could not figure out how to boost::serialize the following object: Basically, to maintain a big chunk of small objects, I use a memory pool to allocate a big trunk of memory and return the pointers to small objects. struct small { int size; int * ptr; init(int s, int* p){ size = s; ptr = p; } } struct All { vector<int> data; vector<small> objs; All(int num_obj, int size_obj) { data.resize( num_obj * size_obj); for(int i=0; i<num_obj; i++) objs[i].init( size_obj, &data[i* size_obj]); } } It is easy to serialize All::data but how to deal with small::ptr is beyond me. I tried the following ways: 1. in small ar & size & ptr. --- template expansion error. 2. in small ar & size & reinterpret_cast<unsigned int>ptr --- core dump. What I am trying to do in 2 is that in load(....), I want to ar & objs; /// get the number of old pointer back. find the smallest number of objs[i].ptr relocate objs[i].ptr to &data[0] + objs[i].ptr - smallest point. However, I can not do this in the load(...) function. The template expansion does not allow changes to objs (this does not make sense to me though). 3. ignore ptr --- can compile, core dump. Can someone give me a bit of insights how I can make things work? Thanks.

On Sun, Jul 18, 2004 at 09:28:47PM -0500, Bo Peng wrote: It turns out that the library is buggy. I change ar & vector_of_small_objs to for(....) ar & vector_of_small_objs[i] and it works now. Is this the reason why serialization is not yet part of boost distribution? -- Bo Peng

On Sun, Jul 18, 2004 at 11:44:12PM -0500, Bo Peng wrote:
On Sun, Jul 18, 2004 at 09:28:47PM -0500, Bo Peng wrote: and it works now.
No. I still get core dump from time to time. I also notice that many serializaton examples core dump (I tried three) on my system. Can anyone confirm this? I am using redhat 9 with kernel 2.4.20-31.9, gcc-3.2.2-5, boost-1.31-0, serialization20.zip . Some error messages are: # demo original schedule 6:24 bob 0x0x814b400 34135'52.56" 13422'78.3" 24th Street and 10th Avenue 0x0x814b428 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 0x0x814b998 35136'15.456" 13332'15.3" White House 9:57 bob 0x0x814b400 34135'52.56" 13422'78.3" 24th Street and 10th Avenue 0x0x814b428 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 0x0x814b998 35136'15.456" 13332'15.3" White House 11:2 alice 0x0x814b400 34135'52.56" 13422'78.3" 24th Street and 10th Avenue 0x0x814b428 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 0x0x814b998 35136'15.456" 13332'15.3" White House 7:17 ted 0x0x814b9c0 35134'48.789" 13332'16.23" Lincoln Memorial 0x0x814b998 35136'15.456" 13332'15.3" White House 0x0x814b428 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 9:38 ted 0x0x814b9c0 35134'48.789" 13332'16.23" Lincoln Memorial 0x0x814b998 35136'15.456" 13332'15.3" White House 0x0x814b428 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 11:47 alice 0x0x814b9c0 35134'48.789" 13332'16.23" Lincoln Memorial 0x0x814b998 35136'15.456" 13332'15.3" White House 0x0x814b428 35137'23.456" 13335'54.12" State street and Cathedral Vista LaneAborted (core dumped) # demo_xml original schedule 6:24 bob 0x0x8175260 34135'52.56" 13422'78.3" 24th Street and 10th Avenue 0x0x8175288 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 0x0x81757f8 35136'15.456" 13332'15.3" White House 9:57 bob 0x0x8175260 34135'52.56" 13422'78.3" 24th Street and 10th Avenue 0x0x8175288 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 0x0x81757f8 35136'15.456" 13332'15.3" White House 11:2 alice 0x0x8175260 34135'52.56" 13422'78.3" 24th Street and 10th Avenue 0x0x8175288 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 0x0x81757f8 35136'15.456" 13332'15.3" White House 7:17 ted 0x0x8175820 35134'48.789" 13332'16.23" Lincoln Memorial 0x0x81757f8 35136'15.456" 13332'15.3" White House 0x0x8175288 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 9:38 ted 0x0x8175820 35134'48.789" 13332'16.23" Lincoln Memorial 0x0x81757f8 35136'15.456" 13332'15.3" White House 0x0x8175288 35137'23.456" 13335'54.12" State street and Cathedral Vista Lane 11:47 alice 0x0x8175820 35134'48.789" 13332'16.23" Lincoln Memorial 0x0x81757f8 35136'15.456" 13332'15.3" White House demo_xml: ../../../libs/serialization/example/demo_xml.cpp:21: void save_schedule(const bus_schedule&): Assertion `ofs.good()' failed. 0x0x8175288 35137'23.456" 13335'54.12" State street and Cathedral Vista LaneAborted (core dumped) -- Bo Peng

On Mon, 19 Jul 2004 02:10:03 -0500, Bo Peng wrote
On Sun, Jul 18, 2004 at 11:44:12PM -0500, Bo Peng wrote:
On Sun, Jul 18, 2004 at 09:28:47PM -0500, Bo Peng wrote: and it works now.
No. I still get core dump from time to time. I also notice that many serializaton examples core dump (I tried three) on my system. Can anyone confirm this? I am using redhat 9 with kernel 2.4.20-31.9, gcc-3.2.2-5, boost-1.31-0, serialization20.zip .
There are still some open issues with getting all the serialization tests working. As of yesterday this exact same failure was occuring with the latest CVS in the regression reports: http://boost.sourceforge.net/regression-logs/cs-LinuxMandrake-links.html#ser... You can find more of these at: http://boost.sourceforge.net/regression-logs/ http://www.boost.org/status/compiler_status.html HTH, Jeff
participants (2)
-
Bo Peng
-
Jeff Garland