SIGSEGV on serializing Map object

General help with the eC language.
Post Reply
nicktick
Posts: 17
Joined: Tue Nov 13, 2012 8:34 pm

SIGSEGV on serializing Map object

Post by nicktick »

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(); 
  }
}
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: SIGSEGV on serializing Map object

Post by jerome »

Hi nicktick!

Confirmed. Map Serialization/Unserialization does not work yet.

I will try to implement it for you tonight :)

Regards,

Jerome
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: SIGSEGV on serializing Map object

Post by jerome »

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
nicktick
Posts: 17
Joined: Tue Nov 13, 2012 8:34 pm

Re: SIGSEGV on serializing Map object

Post by nicktick »

thanks !
nicktick
Posts: 17
Joined: Tue Nov 13, 2012 8:34 pm

Re: SIGSEGV on serializing Map object

Post by nicktick »

One more question:
Is eC's serialized object platform independent? or binary compatible on different OS?
jerome
Site Admin
Posts: 608
Joined: Sat Jan 16, 2010 11:16 pm

Re: SIGSEGV on serializing Map object

Post by jerome »

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
Post Reply