<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Calibri Light";
        panose-1:2 15 3 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
p.MsoNoSpacing, li.MsoNoSpacing, div.MsoNoSpacing
        {mso-style-priority:1;
        margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Eliot,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks for the examples; I have a problem with this one:</p>
<p class="MsoNormal"><o:p> </o:p></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"><o:p> </o:p></p>
<p class="MsoNormal">It gives me MNU: UndefinedObject>>wait</p>
<p class="MsoNormal"><o:p> </o:p></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"><o:p> </o:p></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>
<p class="MsoNormal"><o:p> </o:p></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"><o:p> </o:p></p>
<p class="MsoNormal">I’ll keep looking at it but wanted to let you know…</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Jaromir</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNoSpacing"><span lang="CS">--</span></p>
<p class="MsoNoSpacing"><strong><span style="font-family:"Calibri Light",sans-serif;color:#333333;font-weight:normal">Jaromír Matas</span></strong><span style="font-family:"Calibri Light",sans-serif;color:#555555"><o:p></o:p></span></p>
<p class="MsoNoSpacing"><span style="font-family:"Calibri Light",sans-serif;color:#2E75B6">mail@jaromir.net</span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:eliot.miranda@gmail.com">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">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"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Sat, Jun 25, 2022 at 1:50 AM Jaromir Matas <<a href="mailto:mail@jaromir.net">mail@jaromir.net</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
Hi Eliot,</p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
I missed that one, sorry. </p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
I’ve just tried this example and only got an assertion error (without your fix):</p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
 </p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
p := [] newProcess suspendedContext: nil.</p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
p signalException: Error</p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
 </p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;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"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">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.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">So the example to test is<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">p := [Semaphore new wait] fork.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">Processor yield.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">p signalException: Notification<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">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<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">p := [Semaphore new wait] fork.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">Processor yield.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">p terminate.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">p signalException: Notification<o:p></o:p></span></p>
</div>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">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.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
Thanks!</p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
Jaromir</p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
 </p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;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="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
 </p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt;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="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:9.6pt">
 </p>
</div>
</div>
<p class="MsoNormal" style="margin-left:9.6pt"><o:p> </o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:12.0pt">_,,,^..^,,,_<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
<p class="MsoNormal"><span style="font-size:12.0pt">best, Eliot<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>