[Vm-dev] Socket's readSemaphore is losing signals with Cog on Linux

Levente Uzonyi leves at elte.hu
Sat Aug 13 11:42:14 UTC 2011


Hi,

Socket's readSemaphore is losing signals with CogVMs on linux. We found 
several cases (RFB, PostgreSQL) when processes are stuck in the following 
method:

Socket >> waitForDataIfClosed: closedBlock
 	"Wait indefinitely for data to arrive.  This method will block until
 	data is available or the socket is closed."

 	[
 		(self primSocketReceiveDataAvailable: socketHandle)
 			ifTrue: [^self].
 		self isConnected
 			ifFalse: [^closedBlock value].
 		self readSemaphore wait ] repeat

When we inspect the contexts, the process is waiting for the 
readSemaphore, but evaluating (self primSocketReceiveDataAvailable: 
socketHandle) yields true. Signaling the readSemaphore makes the process 
running again. As a workaround we replaced #wait with #waitTimeoutMSecs: 
and all our problems disappeared.

The interpreter VM doesn't seem to have this bug, so I guess the bug was 
introduced with the changes of aio.c.


Cheers,
Levente


More information about the Vm-dev mailing list