<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 25, 2022 at 1:50 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_7802342364980918836WordSection1">
<p class="MsoNormal">Hi Eliot,</p>
<p class="MsoNormal">I missed that one, sorry. </p>
<p class="MsoNormal">I’ve just tried this example and only got an assertion error (without your fix):</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">p := [] newProcess suspendedContext: nil.</p>
<p class="MsoNormal">p signalException: Error</p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I just can’t figure out in which case you got the BCR exception :)</p></div></div></blockquote><div><br></div><div class="gmail_default" style="font-size:small">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.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">So the example to test is</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">p := [Semaphore new wait] fork.</div><div class="gmail_default" style="font-size:small">Processor yield.</div><div class="gmail_default" style="font-size:small">p signalException: Notification</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">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</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><div class="gmail_default">p := [Semaphore new wait] fork.</div><div class="gmail_default">Processor yield.</div><div class="gmail_default">p terminate.</div><div class="gmail_default">p signalException: Notification</div></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">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.</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_7802342364980918836WordSection1">
<p class="MsoNormal">Thanks!</p>
<p class="MsoNormal">Jaromir</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: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"><u></u> <u></u></p>
<p class="MsoNormal" style="margin-bottom:12pt">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!<br>
<br>
<u></u><u></u></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>