<br><br><div class="gmail_quote">On Sun, Mar 10, 2013 at 9:53 AM, Nicolas Cellier <span dir="ltr">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
I&#39;d like to understand this.<br></blockquote><div><br></div><div>Me too.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
MC mecahnism should invoke primitive 116 (primitiveFlushCacheByMethod,<br>
CompiledMethod&gt;&gt;flushCache) on OLD CompiledMethod when recompiled in<br>
newClass.<br>
This will invoke<br>
<br>
cogit unlinkSendsTo: self stackTop andFreeIf: false<br>
<br>
where stackTop is the old CM.<br></blockquote><div><br></div><div>Can we step back and move to the abstract?  What the Cog VM does in response to aMethod primitiveFlushCacheByMethod is remove all cache entries pointing to aMethod.  That&#39;s both in the first-level method lookup cache, and in any inline caches that point to aMethod.  What it won&#39;t (and can&#39;t do) is alter any existing activations of aMethod.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
But for some reason - ClassBuilder is relatively complex - the<br>
recompilation is invoked with an empty MethodDictionary, so this<br>
primitive is not invoked.<br>
<br>
primitive 119 (primitiveFlushCacheSelective, Symbol&gt;&gt;flushCache) is<br>
invoked then, but will apparently not cogit unlinkAnything.<br></blockquote><div><br></div><div>But in response to aSelector primitiveFlushCacheSelective Cog will remove all cache entries using aSelector  That&#39;s both in the first-level method lookup cache, and in any inline caches that point to a method whose selector is aSelector.   What it won&#39;t (and can&#39;t do) is alter any existing activations of methods whose selectors are aSelector.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
The super hammer primitive 89 (primitiveFlushCache,<br>
Behavior&gt;&gt;flushCache) would unlink thru flushMethodCache which:<br>
<br>
cogit unlinkAllSends<br>
<br>
But, primitive 89 is not invoked in MC createClass process.<br>
<br>
If I add Object flushCache at the end of ClassBuilder&gt;&gt;mutate:to:, I<br>
can download various versions of Compiler without trouble.<br>
Is my cache analysis correct and could it be the origin of the problem?<br></blockquote><div><br></div><div>We still need to understand what the bug is.  What we saw was that an activation of a Parser method that was compiled for Parser before it was shape-changed was still on the stack after Parser had been shape-changed.  So the old method ended up reading off the end of the Parser instance.  So the first question is</div>
<div><br></div><div>- is the method on the stack there before shape-change or not?</div><div><br></div><div>If it is, then the bug is not with the VM but in the system keeping that old method in use whole it shape-changes Parser.</div>
<div><br></div><div>If it is not, then it would seem to be a VM bug or a cache-flushing bug and the question is how did the old method get activated?</div><div><br></div><div>The second question would be simple to answer if it was the case that the method&#39;s selector didn&#39;t get flushed.  But you&#39;re saying the class builder did flush the method&#39;s selector.</div>
<div><br></div><div>(sorry I haven&#39;t had enough time to focus on this)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
Nicolas<br>
<br>
2013/3/8 Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;:<br>
&gt; 2013/3/8 Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;:<br>
&gt;&gt; To illustrate it, see the attached stack trace when I attempt to load<br>
&gt;&gt; an OrderedCollection(a MCVersion(Compiler-eem.252)) from an up to date<br>
&gt;&gt; trunk image:<br>
&gt;&gt;<br>
&gt;<br>
&gt; Grrr, sorry, I tried so many combinations...<br>
&gt; This was not an up-to-date Squeak image, I at least reverted my last<br>
&gt; version of Metacello in order to trigger this simple bad behaviour.<br>
&gt; So the recipe would be to load first Monticello-fbs.532 then<br>
&gt; Compiler-eem.252 from an up-to-date trunk image with a COG VM (no<br>
&gt; crash this way back, beacuse we add slots) and attempt the same with<br>
&gt; an Interpreter VM (no problem at all).<br>
&gt;<br>
&gt; Nicolas<br>
&gt;<br>
&gt;&gt; No obsolete Parser/Compiler compiledMethod sender on the call stack,<br>
&gt;&gt; but an obsolete Parser compiledMethod disagreeing on cue position,<br>
&gt;&gt; sent AFTER the recompilation of Parser, which is not expected.<br>
&gt;&gt;<br>
&gt;&gt; No such Behavior with interpreter VM, for me it is clearly a COG VM<br>
&gt;&gt; bug, some cache is not properly flushed or something...<br>
&gt;&gt;<br>
&gt;&gt; Nicolas<br>
&gt;&gt;<br>
&gt;&gt; 2013/3/8 Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>&gt;:<br>
&gt;&gt;&gt; 2013/3/8 Jeff Gonis &lt;<a href="mailto:jeff.gonis@gmail.com">jeff.gonis@gmail.com</a>&gt;:<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On Fri, Mar 8, 2013 at 10:49 AM, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; This is known.  It is a bug in the update. not the VM.  The update<br>
&gt;&gt;&gt;&gt;&gt; causes the VM to read off the end of a Parser instance.  It would<br>
&gt;&gt;&gt;&gt;&gt; crash the Interpreter VM too.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; best,<br>
&gt;&gt;&gt;&gt;&gt; Eliot<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Hmm, looking at it again, I&#39;m not convinced.<br>
&gt;&gt;&gt; First, I tried several times from an Interpreter Vm and that never<br>
&gt;&gt;&gt; triggered any bug.<br>
&gt;&gt;&gt; Then I don&#39;t see how the update could fail.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In MCClassDefinition&gt;&gt;createClass we use<br>
&gt;&gt;&gt; class := (ClassBuilder new)<br>
&gt;&gt;&gt;                         name: name<br>
&gt;&gt;&gt;                         inEnvironment: superClass environment<br>
&gt;&gt;&gt;                         subclassOf: superClass<br>
&gt;&gt;&gt;                         type: type<br>
&gt;&gt;&gt;                         instanceVariableNames: self instanceVariablesString<br>
&gt;&gt;&gt;                         classVariableNames: self classVariablesString<br>
&gt;&gt;&gt;                         poolDictionaries: self sharedPoolsString<br>
&gt;&gt;&gt;                         category: category.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; This is a quite robust process, because it creates a newClass clone<br>
&gt;&gt;&gt; first, compile all the methods from oldClass into newClass, and then<br>
&gt;&gt;&gt; mutate allInstances of oldClass into instances of newClass.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; What can fail is having an obsolete CompiledMethod on stack with wrong<br>
&gt;&gt;&gt; inst var slots.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; What I observed with COG VM is different.<br>
&gt;&gt;&gt; I change Parser with above ClassBuilder snippet.<br>
&gt;&gt;&gt; Then in previous version of createClass, this snippet fails in<br>
&gt;&gt;&gt; (Compiler evaluate: ...) part :<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         composition := Compiler evaluate: (self traitComposition ifNil:[&#39;{}&#39;]).<br>
&gt;&gt;&gt;         (composition isCollection and:[composition isEmpty and:[class<br>
&gt;&gt;&gt; traitComposition isEmpty]]) ifFalse:[<br>
&gt;&gt;&gt;                 class setTraitComposition: composition asTraitComposition.<br>
&gt;&gt;&gt;         ].<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; with an obsolete Parser method...<br>
&gt;&gt;&gt; It&#39;s like COG VM is still using an old Parser methodDictionary, while<br>
&gt;&gt;&gt; we just changed it...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Nicolas<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Ok thanks, I wasn&#39;t sure if this was the same bug and I figured it was<br>
&gt;&gt;&gt;&gt; safer to send in a report than not.  Didn&#39;t mean to spam the list.<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Thanks for your time,<br>
&gt;&gt;&gt;&gt; Jeff<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>