<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Jaromir,</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 26, 2022 at 10:03 AM Jaromir Matas <<a href="mailto:mail@jaromir.net">mail@jaromir.net</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 lang="EN-US" style="word-wrap:break-word">
<div class="gmail-m_-6038714441924635243WordSection1">
<p class="MsoNormal">Hi Eliot,</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks for the examples; I have a problem with this one:</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">p := [Semaphore new wait] fork.</p>
<p class="MsoNormal">Processor yield.</p>
<p class="MsoNormal">p signalException: Notification</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">It gives me MNU: UndefinedObject>>wait</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">The reason is:</p>
<p class="MsoNormal">1) you place the new context (Notification signal) on top of the previous suspendedContext (Semaphore new wait); its pc is at the wait.</p>
<p class="MsoNormal">2) now when the (Notification signal) context finally returns it places its return value on the top of its senders stack -> and this is a problem because when you send the wait it takes the stack top as the receiver (but that’s changed
 in the meantime) if I understand it correctly – resulting in the MNU</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Is this a bug? I’ve never used #signalException so I’m not entirely sure what to expect from it but it behaves differently than in 5.3.</p></div></div></blockquote><div><br></div><div class="gmail_default" style="font-size:small">It's a bug in the implementation of signalException:.  I should have seen it earlier.  It is the reason Context>>#jump exists.  Let me think about the right solution for a while and I'll commit a fix soon.</div><div class="gmail_default" style="font-size:small"><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 lang="EN-US" style="word-wrap:break-word"><div class="gmail-m_-6038714441924635243WordSection1">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Enclosing a screen snip. If, at that moment, you do suspendedContext pop, the computation will proceed as expected.</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I’ll keep looking at it but wanted to let you know…</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Jaromir</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="gmail-m_-6038714441924635243MsoNoSpacing"><span lang="CS">--</span></p>
<p class="gmail-m_-6038714441924635243MsoNoSpacing"><strong><span style="font-family:"Calibri Light",sans-serif;color:rgb(51,51,51);font-weight:normal">Jaromír Matas</span></strong><span style="font-family:"Calibri Light",sans-serif;color:rgb(85,85,85)"><u></u><u></u></span></p>
<p class="gmail-m_-6038714441924635243MsoNoSpacing"><span style="font-family:"Calibri Light",sans-serif;color:rgb(46,117,182)"><a href="mailto:mail@jaromir.net" target="_blank">mail@jaromir.net</a></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:eliot.miranda@gmail.com" target="_blank">Eliot Miranda</a><br>
<b>Sent: </b>Saturday, June 25, 2022 21:12<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">The general-purpose Squeak developers list</a><br>
<b>Subject: </b>Re: [squeak-dev] The Trunk: Kernel-eem.1484.mcz</p>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Sat, Jun 25, 2022 at 1:50 AM Jaromir Matas <<a href="mailto:mail@jaromir.net" target="_blank">mail@jaromir.net</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal" style="margin-left:9.6pt">
Hi Eliot,</p>
<p class="MsoNormal" style="margin-left:9.6pt">
I missed that one, sorry. </p>
<p class="MsoNormal" style="margin-left:9.6pt">
I’ve just tried this example and only got an assertion error (without your fix):</p>
<p class="MsoNormal" style="margin-left:9.6pt">
 </p>
<p class="MsoNormal" style="margin-left:9.6pt">
p := [] newProcess suspendedContext: nil.</p>
<p class="MsoNormal" style="margin-left:9.6pt">
p signalException: Error</p>
<p class="MsoNormal" style="margin-left:9.6pt">
 </p>
<p class="MsoNormal" style="margin-left:9.6pt">
I just can’t figure out in which case you got the BCR exception :)</p>
</div>
</div>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">In the VMMaker VM simulator, when the simulator window is closed, the closing code attempts to close any and all notifiers & debuggers .  I'm working on the threaded FFI plugin, which in the simulator has
 multiple Smalltalk processes emulating OS threads.  To close each notifier it needs to deliver a tagged Notification signal to the relevant process.  Some of these processes are waiting on semaphores.  If they are the old code would suspend, which would set
 the process's suspendedContext to nil, and result in a cannot return error as the signal was being delivered.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">So the example to test is<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">p := [Semaphore new wait] fork.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">Processor yield.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">p signalException: Notification<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">With the old signalException: version and the new suspend primitive this would crash with the BCR error.  Or something like that.  Maybe it had to be terminated, as in<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">p := [Semaphore new wait] fork.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">Processor yield.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">p terminate.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">p signalException: Notification<u></u><u></u></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">But you get the idea.  If the process's suspendedContext is nil then the context that is put on top of the stack towards the end of signalException: will not be able to return.<u></u><u></u></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12pt"><u></u> <u></u></span></p>
</div>
<blockquote style="border-style:none none none solid;border-left-width:1pt;border-left-color:rgb(204,204,204);padding:0in 0in 0in 6pt;margin:5pt 0in 5pt 4.8pt">
<div>
<div>
<p class="MsoNormal" style="margin-left:9.6pt">
Thanks!</p>
<p class="MsoNormal" style="margin-left:9.6pt">
Jaromir</p>
<p class="MsoNormal" style="margin-left:9.6pt">
 </p>
<div style="border-style:solid none none;border-top-width:1pt;border-top-color:rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal" style="margin-left:9.6pt">
<b>From: </b><a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a><br>
<b>Sent: </b>Saturday, June 25, 2022 1:58<br>
<b>To: </b><a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">squeak-dev@lists.squeakfoundation.org</a>;
<a href="mailto:packages@lists.squeakfoundation.org" target="_blank">packages@lists.squeakfoundation.org</a><br>
<b>Subject: </b>[squeak-dev] The Trunk: Kernel-eem.1484.mcz</p>
</div>
<p class="MsoNormal" style="margin-left:9.6pt">
 </p>
<p class="MsoNormal" style="margin-bottom:12pt;margin-left:9.6pt">
Eliot Miranda uploaded a new version of Kernel to project The Trunk:<br>
<a href="http://source.squeak.org/trunk/Kernel-eem.1484.mcz" target="_blank">http://source.squeak.org/trunk/Kernel-eem.1484.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: Kernel-eem.1484<br>
Author: eem<br>
Time: 24 June 2022, 4:58:09.258613 pm<br>
UUID: f8ca934f-5875-434a-8cec-4d055099bdb6<br>
Ancestors: Kernel-mt.1483<br>
<br>
Fix a bug in Process>>signalException: where signalling a suspended process would cause a cannot return exception.<br>
<br>
=============== Diff against Kernel-mt.1483 ===============<br>
<br>
Item was changed:<br>
  ----- Method: Process>>signalException: (in category 'signaling') -----<br>
  signalException: anException<br>
         "Signal an exception in the receiver process...if the receiver is currently<br>
         suspended, the exception will get signaled when the receiver is resumed.  If
<br>
         the receiver is blocked on a Semaphore, it will be immediately re-awakened<br>
         and the exception will be signaled; if the exception is resumed, then the receiver<br>
         will return to a blocked state unless the blocking Semaphore has excess signals"<br>
  <br>
         "If we are the active process, go ahead and signal the exception"<br>
          self isActiveProcess ifTrue: [^anException signal].<br>
  <br>
         "Suspend myself first to ensure that I won't run away<br>
          in the midst of the following modifications."<br>
+        self isSuspended ifFalse:<br>
+                [self suspend].<br>
+        suspendedContext ifNil: [self error: 'no suspended context!!!!'].<br>
+        suspendedContext := Context<br>
-         self suspend.<br>
-         suspendedContext := Context<br>
                                                                 sender: suspendedContext<br>
                                                                 receiver: anException<br>
                                                                 method: (anException class lookupSelector: #signal)<br>
                                                                 arguments: #().<br>
+        ^self resume!<br>
-         ^self resume!</p>
<p class="MsoNormal" style="margin-left:9.6pt">
 </p>
</div>
</div>
<p class="MsoNormal" style="margin-left:9.6pt"><u></u> <u></u></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12pt">_,,,^..^,,,_<u></u><u></u></span></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span style="font-size:12pt">best, Eliot<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</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>