Hangs in fopen() in multi-threaded app

Brian C. Wiles bwiles_cygwin@poldon.com
Fri Jan 21 07:05:00 GMT 2005


   I am writing an app that for the most part uses only one thread but 
creates a temporary thread once in a while to generate reports and email 
them.  The problem is when the second thread attempts to fopen() a file 
for writing, it hangs.  The main thread continues to run until the next 
time it calls a file function (in my case, fclose() hangs).  I 
experience the same hangs even when I protect the code with a mutex.

   Here's where it gets interesting.  If I run this under my native 
desktop OS (Windows XP Pro), it works fine.  The hanging only happens on 
my VMWare test system.  Plus, my system is a P4 3.06 GHz with 
Hyperthreading.  I have experienced some random (although infrequent) 
hangs on the native OS when running bash, etc., but I can never 
reproduce them at the same spot.  In my application, it always hangs in 
fopen().

   This leads me to ask the following:

     1.) Would the known Hyperthreading issues in Cygwin happen in a 
VMWare machine and not the native host?  (I suppose I could disable HT 
and see if it makes a difference, which I'll post the results of.)

     2.) Is there anything in the file I/O routines that are not 
thread-safe?

     3.) Is there something else I need to do in order to avoid this 
type of deadlock?

   If a code sample would help, I could post one (or send privately). 
My app is open source, so I'd be willing to send it off to someone if 
they'd be interested.  Thanks for any ideas.

     -Brian

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list