<div dir="ltr">Hi Henry, Hi Marcus,<div class="gmail_extra"><br><div class="gmail_quote">On Sun, Aug 13, 2017 at 5:08 AM, henry <span dir="ltr"><<a href="mailto:henry@callistohouse.club" target="_blank">henry@callistohouse.club</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"><div>Hi all. I was testing with this eventual_test package and it blows up the pharo 6.1 vm. I'd welcome pointers<br></div><div><br></div><div><a href="http://www.squeaksource.com/TurquoiseTesting.html" target="_blank">http://www.squeaksource.com/<wbr>TurquoiseTesting.html</a><br></div><div><br></div><div class="gmail-m_7806948026423193907protonmail_signature_block"><div class="gmail-m_7806948026423193907protonmail_signature_block-user">- HH</div></div></blockquote><div><br></div><div>I took a look at this and I think you've found a bug in the mustBeBooleanMagic: code.  What's happening is a mustBeBoolean in Integer>>* due to evaluating</div><div>    10 * 42 eventual</div><div>in RefsTest>>testFailureArithmeticPrimitivesWithPromiseArgument</div><div><br></div><div>Since 42 eventual is a NearERef the SmallInteger>>* primitive fails and does ^super * anInteger (where anInteger is the NearERef).  So that evaluates Integer>>*</div><div><br></div><div>Integer>>* aNumber</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>"Refer to the comment in Number * " </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>aNumber isInteger ifTrue:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">              </span>[^ self digitMultiply: aNumber </div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                                       </span>neg: self negative ~~ aNumber negative].</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">       </span>^ aNumber adaptToInteger: self andSend: #*</div><div><br></div><div>aNumber, being a NearERef, answers a PromiseERef for the isInteger send, and this provokes a mustBeBoolean for the isInteger ifTrue: [...</div><div><br></div><div>After the mustBeBooleanMagic: the stack looks wrong. The activation of Integer>>*, which is about to do</div><div>    ^ aNumber adaptToInteger: self andSend: #*</div><div>does not have enough items on the stack.  Instead of containing</div><div>    a NearERef (for 42)</div><div>    10</div><div>     #*</div><div>it contains</div><div>    a PromiseERef (for 42 eventual isInteger)</div></div><br>and the send of #adaptToInteger:andSend: ends up taking more form the stack than the VM can handle and it crashes.  The bug appears to be with the use of sendNode irInstruction nextBytecodeOffsetAfterJump in Object>>mustBeBooleanMagic: since execution should resume at bytecode 55 below, but does so at bytecode 57<br clear="all"><br><div class="gmail_extra">41 <10> pushTemp: 0</div><div class="gmail_extra">42 <D0> send: isInteger</div><div class="gmail_extra">43 <AC 09> jumpFalse: 54</div><div class="gmail_extra">45 <70> self</div><div class="gmail_extra">46 <10> pushTemp: 0</div><div class="gmail_extra">47 <70> self</div><div class="gmail_extra">48 <D1> send: negative</div><div class="gmail_extra">49 <10> pushTemp: 0</div><div class="gmail_extra">50 <D1> send: negative</div><div class="gmail_extra">51 <E2> send: ~~</div><div class="gmail_extra">52 <F3> send: digitMultiply:neg:</div><div class="gmail_extra">53 <7C> returnTop</div><div class="gmail_extra">54 <10> pushTemp: 0</div><div class="gmail_extra">55 <70> self</div><div class="gmail_extra">56 <24> pushConstant: #*</div><div class="gmail_extra">57 <F5> send: adaptToInteger:andSend:</div><div class="gmail_extra">58 <7C> returnTop</div><div class="gmail_extra"><br></div><div class="gmail_extra">So the positioning of the context's pc must be before any argument marshaling for the next send, not simply the send itself.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Put a breakpoint at the end of Object>>mustBeBooleanMagic: and add initlaPC and resumePC temporaries at the beginning and capture them via</div><div class="gmail_extra">    initialPC := context pc.</div><div class="gmail_extra">at the beginning and then</div><div class="gmail_extra"><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre">  </span>context pc: (resumePC := sendNode irInstruction nextBytecodeOffsetAfterJump)</div></div><div class="gmail_extra">to see what I'm seeing.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Phew.  Glad it's not a VM bug :-)</div><div class="gmail_extra"><br></div><div class="gmail_extra">HTH</div><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div><div><br></div></span></div></div></div>
</div></div>