Ecere SDK/eC Forums
http://ecere.org/community/
Print view

SIGSEGV on serializing Map object
http://ecere.org/community/viewtopic.php?f=1&t=354
Page 1 of 1
Author:  nicktick [ Tue Mar 26, 2013 2:39 am ]
Post subject:  SIGSEGV on serializing Map object

Please see the line where commented with "SIGSEGV" in following code.

Code: Select all

class TestClass 
{
   public int x;
   public String str;
   public void Print()
   {
      PrintLn(x);
      PrintLn(str);
   }
}
void test_serialize_map()
{
   File f;
   Map<String, TestClass> data { };
   data["BobsScore"]   = TestClass {1,"1-1"};    
 
   f = FileOpen("savedstuff", write); 
   f.Put(data); 
   delete f;
   delete data;
 
   f = FileOpen("savedstuff", read); 
   f.Get(data);   
   delete f;
   {  
      TestClass t = data["BobsScore"];    //SIGSEGV happened here 
       //how to resolve the SIGSEGV problem ? 
      t.Print();
      delete t;
   }
}   
 
class TestApp : Application
{
   void Main()
   {
      test_serialize_map(); 
  }
}
Author:  jerome [ Tue Mar 26, 2013 12:05 pm ]
Post subject:  Re: SIGSEGV on serializing Map object

Hi nicktick!

Confirmed. Map Serialization/Unserialization does not work yet.

I will try to implement it for you tonight :)

Regards,

Jerome
Author:  jerome [ Thu Mar 28, 2013 12:16 am ]
Post subject:  Re: SIGSEGV on serializing Map object

Hi nicktick!

I just committed a fix for the Map Serialization/Unserialization:

https://github.com/ecere/sdk/commit/224 ... 79c4da1f79
It will be included in today's 0.44.06 release.

Maps didn't work with the generic container serialization, because they must additionally serialize the keys as well as the data.

Your code should now work as expected :D

Regards,

Jerome
Author:  nicktick [ Thu Mar 28, 2013 2:23 am ]
Post subject:  Re: SIGSEGV on serializing Map object

thanks !
Author:  nicktick [ Thu Mar 28, 2013 3:16 am ]
Post subject:  Re: SIGSEGV on serializing Map object

One more question:
Is eC's serialized object platform independent? or binary compatible on different OS?
Author:  jerome [ Thu Mar 28, 2013 9:32 am ]
Post subject:  Re: SIGSEGV on serializing Map object

Hi nicktick!

It is meant to be platform-independent (and thus binary compatible on different OSes and architectures). In particular, it produces the same output regardless of the machine endianness.

The serialization of base types (e.g. uint, uint64, float etc.) takes care of flipping these to big endian. And complex types normally serialize by serializing the simpler types. Thus serialization is in effect serialized to big endian (or 'network' byte order, as it is called). This is all done in ecere/src/com/dataTypes.ec, if you're curious, with the PUT/GET X * macros.

Please let me know if you find an incompatibility :) But I you probably don't have a little-endian platform to test on (e.g. PowerPC).

Regards,

Jerome
All times are UTC-05:00 Page 1 of 1