<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Hi Jaromir,</p>
<p><br>
</p>
<p>thanks a lot for your answer! Great to hear that you have found some other examples that would benefit from my patch as well. :-)</p>
<p><br>
</p>
<p></p>
<div>> A question: why not simply `ctxt restart`? Without assigning to <span style="font-size:12pt">suspendedContext. Like this:</span></div>
<div>> </div>
<div>> #terminate</div>
<div>>                 "... lots of code"</div>
<div>>                 ctxt := self popTo: suspendedContext bottomContext.</div>
<div>>                 ctxt == suspendedContext bottomContext ifFalse:</div>
<div>> >>>                 [ctxt restart.</div>
<div>>                         "self debug: ctxt title: 'Unwind error during termination'"].</div>
<div>>                 "Set the context to its endPC for the benefit of isTerminated."</div>
<div>>                 ctxt pc: ctxt endPC]</div>
<div><br>
</div>
The "ctxt restart" was necessary to have the raised exception handled again after it has been absorbed by #runUntilErrorOrReturnFrom:.
<div>I'm not sure about the exact semantics of suspendedContext, but shouldn't it always point to the latest context frame unless the process is running? Should we rather set suspendedContext to nil here?
<p></p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" 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="x_divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div><font size="2" color="#808080"></font></div>
</div>
</div>
</div>
</div>
<div>That's another point I find questionary about my changeset - if the process refuses to terminate, it will be resumed again, even if it has been suspended before. Can or should we change that or is it already the most logical way (because every "unwinding"
 essentially means to "resume" the process anyway)?</div>
<div>Anyway, I think the method return after restarting the context is necessary because otherwise, its pc will be manipulated which we don't want unless the process has really been terminated.</div>
<div><br>
</div>
<div>#<span>valueUninterruptably is also an interesting example. But this should also have been fixed using my proposal, shouldn't it? :-)</span></div>
<div><span><br>
</span></div>
<div><span>> </span><span style="font-size:12pt">Besides #isTerminated I've been trying to refactor #terminate and </span><span></span><span style="font-size:12pt">#newProcess to avoid 'cannot return' errors and unify different kinds of </span><span></span><span style="font-size:12pt">termination
 (active process termination and suspended process termination).</span><span>
<div><br>
</div>
<div>Nice work!</div>
<div><br>
</div>
<div>Best,</div>
<div>Christoph</div>
</span></div>
<div></div>
<div></div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Squeak-dev <squeak-dev-bounces@lists.squeakfoundation.org> im Auftrag von Jaromir Matas <m@jaromir.net><br>
<b>Gesendet:</b> Dienstag, 9. März 2021 10:54:02<br>
<b>An:</b> squeak-dev@lists.squeakfoundation.org<br>
<b>Betreff:</b> Re: [squeak-dev] Bug in Process>>#terminate | Returning from unwind contexts</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Hi Christopher,<br>
<br>
I've just been wondering what that part of #terminate was for... Thanks for<br>
the answer :)<br>
<br>
I tried a recursive version of your example and it behaves even worse:<br>
<br>
   [self error: 'x1'] ensure: [[self error: 'x2'] ensure: [[[[self error:<br>
'x3'] ensure: [^2]] ensure: [^2]] ensure: [^2]]]<br>
<br>
And this one's bad too - hit Abandon and you get the unwind error right<br>
away:<br>
<br>
   [self error] ensure: [1/0]<br>
<br>
After your fix/workaround they miraculously seem to behave again :)<br>
<br>
A question: why not simply `ctxt restart`? Without assigning to<br>
suspendedContext. Like this:<br>
<br>
#terminate<br>
                "... lots of code"<br>
                ctxt := self popTo: suspendedContext bottomContext.<br>
                ctxt == suspendedContext bottomContext ifFalse:<br>
>>>                 [ctxt restart.<br>
                        "self debug: ctxt title: 'Unwind error during termination'"].<br>
                "Set the context to its endPC for the benefit of isTerminated."<br>
                ctxt pc: ctxt endPC]<br>
<br>
<br>
And finally, I noticed #valueUninterruptably uses return from an unwind<br>
context as well and it doesn't seem to function properly due to the bug (ok<br>
after your fix):<br>
<br>
   [1/0] valueUninterruptably<br>
<br>
First doit generates ZeroDivide, hit Abandon and the next doit shows unwind<br>
error but Proceed will just end the process (I'd expect another ZeroDivide -<br>
am I right?)<br>
<br>
#valueUninterruptably<br>
        "Prevent remote returns from escaping the sender.  Even attempts to<br>
terminate (unwind) this process will be halted and the process will resume<br>
here.  A terminate message is needed for every one of these in the sender<br>
chain to get the entire process unwound."<br>
<br>
        ^ self ifCurtailed: [^ self]<br>
<br>
<br>
Besides #isTerminated I've been trying to refactor #terminate and<br>
#newProcess to avoid 'cannot return' errors and unify different kinds of<br>
termination (active process termination and suspended process termination).<br>
I've sent it to the Inbox for discussion - see here:<br>
<a href="http://forum.world.st/The-Inbox-Kernel-jar-1380-mcz-td5127524.html">http://forum.world.st/The-Inbox-Kernel-jar-1380-mcz-td5127524.html</a><br>
<br>
Thanks,<br>
<br>
<br>
<br>
-----<br>
^[^ Jaromir<br>
--<br>
Sent from: <a href="http://forum.world.st/Squeak-Dev-f45488.html">http://forum.world.st/Squeak-Dev-f45488.html</a><br>
<br>
</div>
</span></font>
</body>
</html>