[Gc] I/O issues

Nicolas Cannasse ncannasse at motion-twin.com
Thu Sep 18 00:53:54 PDT 2008

Nicolas Cannasse a écrit :
> Hello,
> Sorry for the multiple messages recently, we could fix a lot of things 
> thanks to the help of the people on the list.
> We are still experiencing one last issue, which is related to I/O 
> functions.
> In some rare cases, two of our threads get blocked in a I/O function 
> (either recv() , fread() , or __read_nocancel()). The two threads are 
> usually unrelated - one can be a MYSQL response beeing read while the 
> other is reading a file - but they get blocked at the same time. Seems 
> like a deadlock to me.

Ok, we were able to locate the problem :

It seems that using close() in a finalizer results in breaking the file 
descriptor table, and might actually close a fd that is still in use 
somewhere else - sometimes inside a read() - causing havoc in our 

Anybody knows where I can find accurate information about close() 
behavior with pthreads ? It seems it's at least not async-signal-safe.

I would like to know if I just have to move the call outside of the 
finalizer or if each open/close have to be protected from GC signals 
(using GC_do_blocking).


More information about the Gc mailing list