[Vm-dev] bug when instantiating ExternalData (to return void* from FFI)
estebanlm at gmail.com
Tue Aug 22 10:47:50 UTC 2017
Hi Eliot, list
I found a bug :)
With latest VM (32 bits, using PharoVM flavour), I crash the VM when executing this:
^ self call: #(void *giterr_last()) options: #( )
this is a very basic FFI call, and should answer an ExternalData instance (pointing to NULL, in this case).
Digging into it, I found at a point (when instantiating the pointer) it answers nil instead an instantiated ExternalData, and this is because in
otherwise clause is:
[self cppIf: (PharoVM or: [true]) "Leave the old code but ignore it completely unless someone complains."
["some Squeak images include funky fixed subclasses of abstract variable
superclasses. e.g. DirectoryEntry as a subclass of ArrayedCollection.
Allow fixed classes to be instantiated here iff nElements = 0."
(nElements ~= 0 or: [instSpec > self lastPointerFormat]) ifTrue:
numSlots := self fixedFieldsOfClassFormat: classFormat.
fillValue := nilObj]].
So it will always answer nil/NULL.
Now, I don’t know why it was commented out, but since there it says "Leave the old code but ignore it completely unless someone complains.”, I complain :D
Thing is… if I restore old code it works fine.
Question is: should we restore that code? or this shows a deeper problem?
More information about the Vm-dev