Thanks, Levente (and Colin for the reproducible case).  I should be able to look at this towards the end of the week.  Anyone else who wants to eyeball aio.c in the Cog branch against aio.c in the trunk vm is most welcome.<br>
<br><div class="gmail_quote">On Sun, Aug 14, 2011 at 12:44 PM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On Sun, 14 Aug 2011, Andreas Raab wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
On 8/13/2011 13:42, Levente Uzonyi wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Socket&#39;s readSemaphore is losing signals with CogVMs on linux. We found several cases (RFB, PostgreSQL) when processes are stuck in the following method:<br>
<br>
Socket &gt;&gt; waitForDataIfClosed: closedBlock<br>
    &quot;Wait indefinitely for data to arrive.  This method will block until<br>
    data is available or the socket is closed.&quot;<br>
<br>
    [<br>
        (self primSocketReceiveDataAvailable<u></u>: socketHandle)<br>
            ifTrue: [^self].<br>
        self isConnected<br>
            ifFalse: [^closedBlock value].<br>
        self readSemaphore wait ] repeat<br>
<br>
When we inspect the contexts, the process is waiting for the readSemaphore, but evaluating (self primSocketReceiveDataAvailable<u></u>: socketHandle) yields true. Signaling the readSemaphore makes the process running again. As a workaround we replaced #wait with #waitTimeoutMSecs: and all our problems disappeared.<br>

<br>
The interpreter VM doesn&#39;t seem to have this bug, so I guess the bug was introduced with the changes of aio.c.<br>
</blockquote>
<br>
Oh, interesting. We know this problem fairly well and have always worked around by changing the wait in the above to a &quot;waitTimeoutMSecs: 500&quot; which turns it into a soft busy loop. It would be interesting to see if there&#39;s a<br>

</blockquote>
<br></div>
It took a while for us to realize that _this_ bug is responsible for our problems. With RFB we found that the server doesn&#39;t accept input from the client, while it&#39;s still sending the changes of the view when the bug happens, which is every few hours. We thought that it&#39;s the side effect of some changes in recent Squeak versions and we just didn&#39;t care about it. Restarting the RFB client can be done in a second.<br>

With PostgreSQL we thought that our Postgres V3 client has a bug. Our old system uses Postgres V2 client, Seaside 2.8, Squeak 3.9 and interpreter VM and it didn&#39;t have such problem for years.<br>
We recently started migrating it to Postgres V3, Custom web framework, Squeak 4.2 and CogVM.<br>
The main differences between these system are interpreter VM - CogVM and Postgres V2 - V3. We assumed that Cog is identical from this POV and tried to debug the postgres protocol, but when I saw where the processes got stalled I remembered your email from 2009 when you mentioned that you had a similar bug [1].<br>

So I&#39;m pretty sure this bug is Cog specific. Reproducing it seems to be pretty hard, so a code review (with sufficient knowledge :)) is more likely to help solving this issue.<br>
<br>
<br>
Levente<br>
<br>
[1] <a href="http://lists.squeakfoundation.org/pipermail/vm-dev/2009-May/002619.html" target="_blank">http://lists.squeakfoundation.<u></u>org/pipermail/vm-dev/2009-May/<u></u>002619.html</a><div><div></div><div class="h5">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
bug in Cog which causes this. FWIW, here is the relevant portion:<br>
<br>
           &quot;Soft 500ms busy loop - to protect against AIO probs;<br>
           occasionally, VM-level AIO fails to trip the semaphore&quot;<br>
           self readSemaphore waitTimeoutMSecs: 500.<br>
<br>
Cheers,<br>
 - Andreas<br>
<br>
<br>
</blockquote>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>best,<div>Eliot</div><br>