<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 22, 2017 at 3:47 AM, Esteban Lorenzano <span dir="ltr"><<a href="mailto:estebanlm@gmail.com" target="_blank">estebanlm@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><br>
Hi Eliot, list<br>
<br>
I found a bug :)<br>
With latest VM (32 bits, using PharoVM flavour), I crash the VM when executing this:<br>
<br>
LGitError giterr_last.<br>
<br>
LGitError class>>giterr_last<br>
        ^ self call: #(void *giterr_last()) options: #(  )<br>
<br>
this is a very basic FFI call, and should answer an ExternalData instance (pointing to NULL, in this case).<br>
<br>
Digging into it, I found at a point (when instantiating the pointer) it answers nil instead an instantiated ExternalData, and this is because in<br>
<br>
Spur32BitMemoryManager>><wbr>instantiateClass:<wbr>indexableSize:<br>
<br>
otherwise clause is:<br>
<br>
                otherwise: "non-indexable"<br>
                        [self cppIf: (PharoVM or: [true]) "Leave the old code but ignore it completely unless someone complains."<br>
                                ifTrue:<br>
                                        [^nil]<br>
                                ifFalse:<br>
                                        ["some Squeak images include funky fixed subclasses of abstract variable<br>
                                          superclasses. e.g. DirectoryEntry as a subclass of ArrayedCollection.<br>
                                          Allow fixed classes to be instantiated here iff nElements = 0."<br>
                                         (nElements ~= 0 or: [instSpec > self lastPointerFormat]) ifTrue:<br>
                                                [^nil].<br>
                                         numSlots := self fixedFieldsOfClassFormat: classFormat.<br>
                                         fillValue := nilObj]].<br>
<br>
So it will always answer nil/NULL.<br>
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<br>
<br>
Thing is… if I restore old code it works fine.<br>
<br>
Question is: should we restore that code? or this shows a deeper problem?<br></blockquote><div><br></div><div><span style="color:rgb(0,0,0);font-size:12.800000190734863px">OK, I didn't mean to hit send.  Ignore the previous posting.  I made this change because Nicolai Hess </span><a href="http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/2017-August/130685.html" target="_blank" style="font-size:12.800000190734863px">wrote to the Pharo mailing list</a><font color="#000000"><span style="font-size:12.800000190734863px">.  I knew that Squeak relied on the behavior but not Pharo.  So I decided to keep the behavior for Squeak and make it illegal for Pharo.  Now we know that we know that the FFI depends on it.</span></font></div><div><font color="#000000"><span style="font-size:12.800000190734863px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.800000190734863px">Looking at the code the use is here:</span></font></div><div><font color="#000000"><span style="font-size:12.800000190734863px"><br></span></font></div><div><font color="#000000"><span style="font-size:12.800000190734863px">ThreadedFFIPlugin>></span></font>ffiReturnPointer:ofType:in:</div><div>    ...</div><div>    <span class="gmail-Apple-tab-span" style="white-space:pre">                       </span>self remapOop: oop in:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                         </span>[retOop := interpreterProxy </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                                          </span>instantiateClass: interpreterProxy classExternalData </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                                         </span>indexableSize: 0].</div><div>    ...</div><div><br></div><div>Alas InterpreterProxy doesn't provide instantiateClass:, only instantiateClass:indexableSize:.  So the quick fix is to keep the old behavior (that new: 0 works for non-indexable classes) but the right fix is to change the ThreadedFFIPlugin and InterpreterProxy so we can write</div><div><br></div><div><div>    ...</div><div>    <span class="gmail-Apple-tab-span" style="white-space:pre">                 </span>self remapOop: oop in:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                         </span>[retOop := interpreterProxy instantiateClass: interpreterProxy classExternalData].</div><div>    ...</div></div><div><br></div><div>What do people think?</div><div><br></div></div><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>