<div dir="ltr"><div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Christoph,<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Mar 16, 2021 at 3:23 PM Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> wrote:<br></div><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">



<div>

<div id="gmail-m_-8559682734675876283divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi Eliot,</p>
<p><br>
</p>
<p>thanks for fixing it! I still don't understand why the bug only occurred during simulation, but glad you were able to find the cause. :-)</p></div></div></blockquote><div><font face="arial, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, sans-serif">The normal VM is a JIT VM.  That VM has JIT versions of some primitives, and in particular it has JIT versions of the #== and #~~ primitives.  These primitives were correct, hiding the bugs in the interpreter versions. The first time the JIT VM sends a particular message (more accurately if it sends a message and the target method is not in the interpreter's method lookup cache) the VM interprets the method.  The next time, because the method is in the <span style="color:rgb(0,0,0)">interpreter's method</span><span style="color:rgb(0,0,0)"> </span>lookup cache, the method will be JITTED and the machine code will be executed.  So the interpreter version of #== and #~~ are only executed once each early in system startup.  From then on the JIT version is used.</font></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">In simulation primitives are evaluated via the tryPrimitive:withArguments: primitive and this primitive always runs the interpreter's version of a primitive.  Hence in simulation one is always using the interpreter's primitives and so one sees the bug.</div><div class="gmail_default" style="font-size:small"></div><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"><div><div id="gmail-m_-8559682734675876283divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<div id="gmail-m_-8559682734675876283Signature">
<div id="gmail-m_-8559682734675876283divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<div name="divtagdefaultwrapper">
<div>
<div id="gmail-m_-8559682734675876283Item.MessagePartBody">
<div id="gmail-m_-8559682734675876283Item.MessageUniqueBody" style="font-family:wf_segoe-ui_normal,"Segoe UI","Segoe WP",Tahoma,Arial,sans-serif,serif,EmojiFont">
<div dir="ltr">
<div id="gmail-m_-8559682734675876283divtagdefaultwrapper"><font face="Calibri,Helvetica,sans-serif,EmojiFont,Apple Color Emoji,Segoe UI Emoji,NotoColorEmoji,Segoe UI Symbol,Android Emoji,EmojiSymbols">
<div id="gmail-m_-8559682734675876283Signature">
<div style="margin:0px"><font style="font-family:Calibri,Arial,Helvetica,sans-serif,serif,EmojiFont">
<div><font size="3" color="black"><span style="font-size:12pt"><a href="http://www.hpi.de/" rel="noopener noreferrer" id="gmail-m_-8559682734675876283LPNoLP" target="_blank"><font size="2"><span id="gmail-m_-8559682734675876283LPlnk909538"><font color="#757B80"></font></span></font></a></span></font></div>
</font></div>
</div>
</font></div>
</div>
</div>
</div>
<div id="gmail-m_-8559682734675876283Item.MessagePartBody"><br>
</div>
<div id="gmail-m_-8559682734675876283Item.MessagePartBody">Best,</div>
<div id="gmail-m_-8559682734675876283Item.MessagePartBody">Christoph</div>
</div>
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_-8559682734675876283divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Von:</b> Squeak-dev <<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org" target="_blank">squeak-dev-bounces@lists.squeakfoundation.org</a>> im Auftrag von Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>><br>
<b>Gesendet:</b> Dienstag, 16. März 2021 20:43:41<br>
<b>An:</b> The general-purpose Squeak developers list<br>
<b>Betreff:</b> Re: [squeak-dev] #testBecomeForward fails when simulated in a rush</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div style="font-size:small">Hi Christoph,<br>
</div>
</div>
<br>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Sun, Mar 14, 2021 at 8:48 AM Thiede, Christoph <<a href="mailto:Christoph.Thiede@student.hpi.uni-potsdam.de" target="_blank">Christoph.Thiede@student.hpi.uni-potsdam.de</a>> wrote:<br>
</div>
<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">
<div dir="ltr">
<div id="gmail-m_-8559682734675876283gmail-m_-1665041689816893699divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p>Hi all,</p>
<p><br>
</p>
<p>it's Sunday afternoon (at least in my timezone :D) and here's an interesting weekend issue for you, maybe even a bug in the VM:</p>
<p><br>
</p>
<p></p>
<div>p := [ObjectTest new testBecomeForward] newProcess.</div>
<div>p runUntil: [:c | c isDead].</div>
<br>
<p></p>
<p>In my fresh trunk image, this expression always fails, i.e. a TestFailure is raised from the second assertion in the test, <span>pt3 == pt2.</span></p>
<p><span><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px"></span></span></p>
<p style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">
However, w<span style="font-size:12pt">hen running the test normally, i.e. executing the first block without simulation, the test passes as expected.</span></p>
<div>Also, when I try to debug the simulation, the test passes again.<br>
</div>
<p></p>
<p><span><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">But I even inserted a halt around the (pt3 == pt2) and could see that
 it actually </span><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">evaluated to false.</span><br>
</span></p>
<p><br>
</p>
<p><span style="font-size:12pt">And when I change the expression like this, it suddenly passes:</span></p>
<p><span style="font-size:12pt"><br>
</span></p>
<p><span style="font-size:12pt"></span></p>
<div style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">
p := [ObjectTest new testBecomeForward] newProcess.</div>
<div style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols;font-size:16px">
p runUntil: [:c | Smalltalk garbageCollect. c isDead].</div>
<br>
<p></p>
<p><span style="font-size:12pt">What is this? Does the VM require some kind of memory sweep before the object identity consistency is restored again? To me, this looks pretty suspicious at least.</span></p>
</div>
</div>
</blockquote>
<div><font size="4"><br>
</font></div>
<div><font size="4">Thank you.  You've found a bug in the interpreted version of primitive 110.  It read</font></div>
<div><font size="4"><br>
</font></div>
<div>
<div><font face="times new roman, serif" size="4">primitiveIdentical</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>"is the receiver/first argument the same object as the (last) argument?.</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>pop argumentCount because this can be used as a mirror primitive."</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>| thisObject otherObject |</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span><span style="color:rgb(0,0,0)">otherObject</span> := self stackValue: 1.</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span><span style="color:rgb(0,0,0)">thisObject</span> := self stackTop.</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>((objectMemory isOopForwarded: otherObject)</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>or: [argumentCount > 1</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>and: [objectMemory isOopForwarded: thisObject]])</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>ifTrue:</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>[self primitiveFailFor: PrimErrBadArgument]</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>ifFalse:</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>[self pop: argumentCount + 1 thenPushBool: thisObject = otherObject]</font></div>
<div><font size="4"><br>
</font></div>
<div><font size="4">but this is the wrong way around.  It should read</font></div>
<div><font size="4"><br>
</font></div>
<div>
<div><font face="times new roman, serif" size="4">primitiveIdentical</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>"is the receiver/first argument the same object as the (last) argument?.</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>pop argumentCount because this can be used as a mirror primitive."</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>| thisObject otherObject |</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>thisObject := self stackValue: 1.</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>otherObject := self stackTop.</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>((objectMemory isOopForwarded: otherObject)</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>or: [argumentCount > 1</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>and: [objectMemory isOopForwarded: thisObject]])</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>ifTrue:</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>[self primitiveFailFor: PrimErrBadArgument]</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>ifFalse:</font></div>
<div><font face="times new roman, serif" size="4"><span style="white-space:pre-wrap"></span>[self pop: argumentCount + 1 thenPushBool: thisObject = otherObject]</font></div>
<div><font size="4"><br>
</font></div>
<div><font size="4">The invariant on invoking a primitive is that the receiver is unforwarded.  This is because it being the receiver of the message, the message send machinery ensures it is not forwarded (if it was, the cached message
 send logic would fail, and the slow lookup path checks for a forwarded receiver, unforwarding and repeating the send if so).  But primitive arguments could be forwarded.  So primitiveIdentical must check for a potentially forwarded argument.  Stupidly I had
 written this carelessly and had not got the variable names the right way round and hence was checking if the receiver was forwarded, not the argument.</font></div>
</div>
</div>
<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">
<div dir="ltr">
<div id="gmail-m_-8559682734675876283gmail-m_-1665041689816893699divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><span style="font-size:12pt">In SqueakJS, I cannot reproduce the issue, i.e., since </span><a href="https://github.com/codefrau/SqueakJS/pull/117" id="gmail-m_-8559682734675876283gmail-m_-1665041689816893699LPlnk113464" style="font-size:12pt" target="_blank">https://github.com/codefrau/SqueakJS/pull/117</a><span style="font-size:12pt">,
 #testBecomeForward never fails.</span></p>
</div>
</div>
</blockquote>
<div><font size="4">SqueakJS doesn't use transparent forwarding.  You'll also find that it won't fail in a pre-Spur image.</font></div>
<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">
<div dir="ltr">
<div id="gmail-m_-8559682734675876283gmail-m_-1665041689816893699divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif" dir="ltr">
<p><span style="font-size:12pt">Best,</span><br>
</p>
<p><span style="font-size:12pt">Christoph</span></p>
</div>
</div>
</blockquote>
</div>
<div dir="ltr">
<div dir="ltr">
<div><span style="border-collapse:separate"><font size="4">
<div>_,,,^..^,,,_<br>
</div>
<div>best, Eliot</div>
</font></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" 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>