<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Do not worry.<div class="">Now would it be possible to have a test or something like that that would help us</div><div class="">to&nbsp;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- document this part of the system</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>- check that the system is in a coherent state</div><div class=""><br class=""></div><div class="">Stef</div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 09 Mar 2016, at 10:26, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com" class="">eliot.miranda@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Um, under /no/ circumstances do what I'm suggesting below.&nbsp; It will screw up 320bit images completely.&nbsp; I've just turned odd SmallIntegers into SmallFloat54's in 32-bit Squeak.&nbsp; I hope I won't destroy too many people's images.&nbsp; This is perhaps my worst blunder.</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Mar 8, 2016 at 10:38 AM, Eliot Miranda <span dir="ltr" class="">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank" class="">eliot.miranda@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class="">Hi Pavel,<div class="gmail_extra"><br class=""><div class="gmail_quote"><span class="">On Tue, Mar 8, 2016 at 1:40 AM, Pavel Krivanek <span dir="ltr" class="">&lt;<a href="mailto:pavel.krivanek@gmail.com" target="_blank" class="">pavel.krivanek@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class="">Hi,&nbsp;<div class=""><br class=""></div><div class="">there is a strange array of size 1024 in the Pharo image that is not eaten by garbage collector even if no object points to it. I guess it is related to Spur.</div><div class=""><br class=""></div><div class=""><div class="">((Array allInstances select: [ :i | i size = 1024 ])</div><div class="">&nbsp;<span style="white-space:pre-wrap" class="">        </span>select: [ :a | a second = SmallInteger &nbsp;]) pointersTo</div></div><div class=""><br class=""></div><div class="">What is it and is it accessible somehow?</div></div></blockquote><div class=""><br class=""></div></span><div class="">It is indeed the first class table page.&nbsp; It looks like an old bug.&nbsp; The oldest Spur image I can start up has the problem. &nbsp; The way that class table pages are hidden is that they have a class index which is not that of Array.&nbsp; Array is at index 52 in the class table (51 zero-relative, Array identityHash = 51), but it is also at index 17 (16 zero-relative).&nbsp; Array allInstances looks for objects whose class index is 51, hence not seeing the class table pages, which all (but the first) have class index 16.</div><div class=""><br class=""></div><div class="">Luckily we can fix the problem easily, and we can fix another problem at the same time, which is that SmallFloat64 has the wrong hash.</div><div class=""><br class=""></div><div class="">The class table is two-level; a (hidden) array of Arrays.&nbsp; Classes are in the class table at their identityHashes (so that to instantiate a class one copies the class's identity hash into the classIndex of the new instance instead of having to search the class table).&nbsp; But when SmallFloat64 was created in the 32-bit image I forgot to give it the right hash and store it in the class table. &nbsp;(there are no SmallFloat64 instances in a 32-bit image, only in 64-bits).</div><div class=""><br class=""></div><div class="">So we can first change SmallFloat64's hash to 3, which is what the Spur 64-bit VM and image require, and enter it into the first class table page, and then we can make the first class table page disappear.</div><div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class="">| firstClassTablePage clone |</div><div class="">"The first class table page is the first Array instance. Of course this is a bug."</div><div class="">firstClassTablePage := Array someInstance.</div><div class=""><br class=""></div><div class="">"It should contain only nil and classes."</div><div class="">self assert: (firstClassTablePage allSatisfy: [:e| e == nil or: [e isBehavior]]).</div><div class=""><br class=""></div><div class="">"And its first 17 elements should only be the immediate classes and Array, since Array is used as the class pun for class table pages, with index 17 (16 zero-relative)"</div><div class="">self assert: (firstClassTablePage first: 17) asSet = {nil. SmallInteger. Character. Array} asSet.</div><div class=""><br class=""></div><div class=""><div class="">"It just so happens that the second Array is the specialSelectors"</div><div class="">self assert: Array someInstance nextInstance == Smalltalk specialSelectors.</div></div><div class=""><br class=""></div><div class="">"Store SmallFloat64 in the first class table page at index 4 (3 zero-relative)."</div><div class="">firstClassTablePage at: 4 put: SmallFloat64.</div><div class=""><br class=""></div><div class="">"Use the secret set identity hash primitive to set SmallFloat64's identityHash to 3."</div><div class="">SmallFloat64 tryPrimitive: 161 withArgs: #(3).</div><div class=""><br class=""></div><div class="">"Now create an object that looks like Array class, but has identityHash 16."</div><div class="">"Take a shallow copy of Array class."</div><div class="">clone := Array shallowCopy.</div><div class="">"Change it into an Array."</div><div class="">Array adoptInstance: clone.</div><div class="">"Set its identityHash to 16."</div><div class="">clone tryPrimitive: 161 withArgs: #(16).</div><div class="">"Use the adoptInstance: primitive to ``set the class of the firstClassTablePage to the cone''.</div><div class="">&nbsp;or, more accurately, to set the firstClassTablePage's class index to 16."</div><div class="">clone tryPrimitive: 160 withArgs: {firstClassTablePage}</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">With the above done, we can check that everything is ok."</div>self assert: SmallFloat64 identityHash = 3.<div class="">self assert: Array someInstance == Smalltalk specialSelectors.</div><div class="">"A class table page is 1024 slots, contains only nil or behaviours, and contains at least one behaviour (is not all nils).&nbsp; There shouldn't be any that we can find."</div><div class="">self assert: (self systemNavigation allObjects select: [:o| o isArray and: [o size = 1024 and: [(o allSatisfy: [:e| e == nil or: [e isBehavior]]) and: [o anySatisfy: [:e| e isBehavior]]]]]) size = 0</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I recommend you create an update map.&nbsp; Then create a version of kernel with a post-load action, written something like this:</div><div class=""><br class=""></div><div class=""><div class=""><br class=""></div><div class="">(Array someInstance size = 1014</div><div class="">&nbsp;and: [(Array someInstance allSatisfy: [:e| e == nil or: [e isBehavior]])</div><div class="">&nbsp;and: [(firstClassTablePage first: 17) asSet = {nil. SmallInteger. Character. Array} asSet]]) ifTrue:</div><div class=""><span style="white-space:pre-wrap" class="">        </span>[| firstClassTablePage clone |</div><div class=""><span style="white-space:pre-wrap" class="">        </span>firstClassTablePage := Array someInstance.</div><div class=""><span style="white-space:pre-wrap" class="">        </span>self assert: (firstClassTablePage allSatisfy: [:e| e == nil or: [e isBehavior]]).</div><div class=""><span style="white-space:pre-wrap" class="">        </span>self assert: (firstClassTablePage first: 17) asSet = {nil. SmallInteger. Character. Array} asSet.</div><div class=""><span style="white-space:pre-wrap" class="">        </span>firstClassTablePage at: 4 put: SmallFloat64.</div><div class=""><span style="white-space:pre-wrap" class="">        </span>SmallFloat64 tryPrimitive: 161 withArgs: #(3).</div><div class=""><span style="white-space:pre-wrap" class="">        </span>clone := Array shallowCopy.</div><div class=""><span style="white-space:pre-wrap" class="">        </span>Array adoptInstance: clone.</div><div class=""><span style="white-space:pre-wrap" class="">        </span>clone tryPrimitive: 161 withArgs: #(16).</div><div class=""><span style="white-space:pre-wrap" class="">        </span>clone tryPrimitive: 160 withArgs: {Array someInstance}</div><div class=""><span style="white-space:pre-wrap" class="">        </span>self assert: SmallFloat64 identityHash = 3.</div><div class=""><span style="white-space:pre-wrap" class="">        </span>self assert: (Array someInstance first: 4) = {nil. SmallInteger. Character. SmallFloat64}]</div></div><div class=""><br class=""></div><div class="">Then create a second update map to ensure that that version of Kernel is loaded.</div><div class=""><br class=""></div><div class="">I will do this for Squeak immediately.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Apologies.</div><div class=""><br class=""></div><div class="">P.S. Interestingly enough, it shows what a horrible security hole the debugger primitives tryPrimitive:withArgs: and tryNamedPrimitive:withArgs: are.</div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr" class=""><div class="">Cheers,<br class=""></div><div class="">-- Pavel</div></div>
</blockquote></div><div class=""><br class=""></div><div class=""><div dir="ltr" class=""><div class=""><span style="font-size:small;border-collapse:separate" class=""><div class="">_,,,^..^,,,_<br class=""></div><div class="">best,&nbsp;Eliot</div></span></div></div></div>
</div></div>
</blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><div dir="ltr" class=""><div class=""><span style="font-size:small;border-collapse:separate" class=""><div class="">_,,,^..^,,,_<br class=""></div><div class="">best,&nbsp;Eliot</div></span></div></div></div>
</div>
</div></blockquote></div><br class=""></div></body></html>