<p>I think if it interprets pushThisContext and a push and a send to #return:, It have to simulate return of the value of the push (next to pushThisContext) but I don't know how to hack it.</p>
<p>- Jin-oh -</p>
<div class="gmail_quote">2012. 3. 14. ¿ÀÀü 3:37¿¡ "Eliot Miranda" <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>>´ÔÀÌ ÀÛ¼º:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi Yoshiki, Hi Hans-Martin, Hi All,<br><br><div class="gmail_quote">On Tue, Mar 13, 2012 at 10:25 AM, Yoshiki Ohshima <span dir="ltr"><<a href="mailto:Yoshiki.Ohshima@acm.org" target="_blank">Yoshiki.Ohshima@acm.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">At Tue, 13 Mar 2012 10:08:12 -0700,<br>
<div>Eliot Miranda wrote:<br>
><br>
> In this case runUntilErrorOrReturnFrom: aContext should return the sender of the activation of Foo>test and the result to be returned (42). But instead it answers the activation of Foo>test<br>
> and nil. Hence the return in ContextPart>return: isn't simulated and control passes to the next statement, ^666.<br>
><br>
> Once again I'm drawn into the bowels of runUntilErrorOrReturnFrom:<br>
> :) It is my nemesis.<br>
<br>
</div>This seems close to the realm of magic to me. Thank you for looking<br>
into it!<br></blockquote><div><br></div><div>Alas, I find it near to magic too. I understand what's going on. The terminateTo: call in resume: doesn't trip the unwind-protect in runUntilErrorOrReturnFrom: (as it shouldn't; terminateTo: specifically doesn't run unwinds by design). So runUntilErrorOrReturnFrom: doesn't answer the right context to resume. It answers Foo>test instead of Foo>test's sender.</div>
<div><br></div><div>What I don't understand is what is a valid criterion for determining these cases. I can hack the method, special casing it for ContextPart>return: and ContextPart>resume:, but that's not acceptable. So if anyone has the desire to pair on this let me know. Perhaps we could have a go at it over skype sometime soon (not today; already blown a lot of time looking at this ;) ).</div>
<div><br></div><div>In any case I've attached two versions of runUntilErrorOrReturnFrom:, one instrumented, one not, containing a hack that gets the right answer (in this case). Yoshiki, you might play with the uninstrumented one to get you going. Hans-Martin, I think you're one of very few people who could shed light on this.</div>
<div><br></div><div>To use the instrumented one (which prints its arguments and halts between evaluation and deciding what to return) step the debugger up to e.g. the send of return:, inspect thisContext (the context about to be sent return:) and set ContextPart's class var QuickStep to that context (in the inspector evaluate QuickStep := self). Then do step. </div>
<div><br></div><div>At least the hack doesn't make things worse; the tests appear the same.</div><div><br></div><div>So one thing to do is to play with the hack, ad see if it causes problems. Another thing to do is to think about the criterion in the hacked runUntilErrorOrReturnFrom: when one should return from the receiver's receiver, rather from aSender's sender.</div>
<div><br></div><div>I'm cc'ing the Pharo list. Here's Yoshiki's original message and a substantive reply of mine:</div><div><br></div><div><br></div><div>On Tue, Mar 13, 2012 at 3:27 AM, Yoshiki Ohshima <span dir="ltr"><<a href="mailto:Yoshiki.Ohshima@acm.org" target="_blank">Yoshiki.Ohshima@acm.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote> Hello,<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>I noticed that step executing the following code in debugger yields<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>different results:<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>-------------------<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>test<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote> 3 < 4 ifTrue: [<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote> thisContext return: 42].<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote> ^ 666.<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>-------------------<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>In the normal execution, you get 42 as expected, but if you debug it<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>and step execute, #return: does not actually return and you get 666.<br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote><br>
<blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"></blockquote>It appears that the primitive for #terminateTo: is the culprit...<br>
<font color="#888888"><br></font><font color="#888888">-- Yoshiki</font></div><div><font color="#888888"><br></font></div><div>On Tue, Mar 13, 2012 at 10:08 AM, Eliot Miranda <span dir="ltr" style><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="padding-left:1ex;margin-right:0px;border-left-color:rgb(204,204,204);border-left-style:solid;margin-left:0.8ex;margin-bottom:0px;margin-top:0px;border-left-width:1px">
</blockquote>Hi Yoshiki,<br><br>From what I can see so far it is the return value from runUntilErrorOrReturnFrom: in complete: when the debugger executes test's return: call. i.e. the debugged process is in Foo>>test at pc 43:<br>
<br>37 <22> pushConstant: 3<br>38 <23> pushConstant: 4<br>39 <B2> send: <<br>40 <9B> jumpFalse: 45<br>41 <89> pushThisContext: <br>42 <21> pushConstant: 42<br>43 <E0> send: return:<br>
44 <87> pop<br>45 <24> pushConstant: 666<br>46 <7C> returnTop<br><br>The stack in the debugger is <br>Process>>complete:<br>Process>>completeStep:<br>Debugger>>doStep<br><br><br><br>and Process>complete: is <br>
<br>complete: aContext <br><span style="white-space:pre-wrap">        </span>"Run self until aContext is popped or an unhandled error is raised. Return self's new top context, unless an unhandled error was raised then return the signaler context (rather than open a debugger)."<br>
<span style="white-space:pre-wrap">        </span><br><span style="white-space:pre-wrap">        </span>| ctxt pair error |<br><span style="white-space:pre-wrap">        </span>ctxt := suspendedContext.<br><span style="white-space:pre-wrap">        </span>suspendedContext := nil. "disable this process while running its stack in active process below"<br>
<span style="white-space:pre-wrap">        </span>pair := ctxt runUntilErrorOrReturnFrom: aContext.<br><span style="white-space:pre-wrap">        </span>suspendedContext := pair first.<br><span style="white-space:pre-wrap">        </span>error := pair second.<br>
<span style="white-space:pre-wrap">        </span>error ifNotNil: [^ error signalerContext].<br><span style="white-space:pre-wrap">        </span>^ suspendedContext<br><br>where the receiver is the activation of Foo>test, and aContext is the activation of ContextPart>return: (whose receiver is also the receiver of complete:, the activation of Foo>test).<br>
<br>In this case runUntilErrorOrReturnFrom: aContext should return the sender of the activation of Foo>test and the result to be returned (42). But instead it answers the activation of Foo>test and nil. Hence the return in ContextPart>return: isn't simulated and control passes to the next statement, ^666.<br>
<br>Once again I'm drawn into the bowels of runUntilErrorOrReturnFrom: :) It is my nemesis.<br><span style="color:rgb(136,136,136)">-- </span><br><span style="color:rgb(136,136,136)">best,</span><br>
<font color="#888888"><div>Eliot</div></font></div><div>-- </div></div>best,<div>Eliot</div><br>
<br><br>
<br></blockquote></div>