[Gambas-user] Segmentation Fault - Deserialization

T Lee Davidson t.lee.davidson at gmail.com
Thu Jul 16 21:57:48 CEST 2020


On 7/16/20 3:10 PM, Brian G wrote:
> Ok I looked at you project,
> 
> My understanding is that when you use as object or as variant, the serialization includes the name of the class in the stream,
> so that when its recreated Gambas can instantiate the object from the stream because it can read the class name before invoking 
> the _read or _write special methods on that class..
> 
> I guess it should know the name from the - as class name -, But I have never used with a specific class name.
> 
> I have been using this for about a year now, and have always used it that way with as object or variant.
> 
> Is there a reason, you need to use the specific class name when you read and write?
> 
> Thank You
> Brian G
> 

Your understanding appears to be correct.

Using the example given at http://gambaswiki.org/wiki/lang/special/read :
- Write #f1, Item1 As Object 'Writes the class name to the output file,
- Write #f1, Item1 As MyClass 'Does not write the class name to the output file and causes a SegFault upon read.

However, in Matthew's project, changing line 19 to be "Write #hFile, hObj As Object" does not correct the issue since, for some 
reason, the class name is NOT written to the output file.

The question is, why?

I thought perhaps there was a collision between the Class1 {Name} property and the object's .Name property. But, changing the 
symbol name of the user-defined {Name} property did not solve the SegFault.


-- 
Lee


More information about the User mailing list