This is the mail archive of the
mailing list for the Cygwin project.
Re: Randomly hang when compiling Cygwin on Cygwin on Wine
- From: Qian Hong <fracting at gmail dot com>
- To: cygwin <cygwin at cygwin dot com>
- Date: Tue, 15 Mar 2016 22:09:36 +0800
- Subject: Re: Randomly hang when compiling Cygwin on Cygwin on Wine
- Authentication-results: sourceware.org; auth=none
- References: <CALd+sZS-EbkUMgmRCyJUK0LCMo6zydzB1rbM9iZFrAcnbfHCRQ at mail dot gmail dot com> <CALd+sZTRVMuLjwZMjxN6f6JvTtax5rJAUuk_SMXvcQzMzxhirA at mail dot gmail dot com> <20151102143023 dot GC963 at calimero dot vinschen dot de>
- Reply-to: fracting at gmail dot com
On Mon, Nov 2, 2015 at 10:30 PM, Corinna Vinschen
> I don't answer this question conclusively before consulting my lawyer.
Me too, but my lawyer was much more slower, his name is Mr. Flash . ;)
> It *might* be possible. See fhandler_base_overlapped::close(),
> fhandler_base_overlapped::check_later() and flush_async_io(), all three
> in fhandler.cc.
Thanks a lot, your information helps a lot.
The bug is hard, it takes a lot of time to reproduce, but finally we got it!
It is a race condition in the Wine side:
Firstly, the reader process calls NtReadFile(), in Wine's
implementation, NtReadFile() tries to read some data using
read_unix_fd() first, if there is enough data needed it will returns
STATUS_SUCCESS immediately, if no enough data available it will
register an async read service using register_async() and returns
STATUS_PENDING. Ideally this async service will either get some data
and wake up the reader process if more data coming form writer, or get
nothing but wake up the reader process telling the pipe is broken if
the writer close the pipe.
However, unfortunately, in some very rare case, the writer process
close the writer handle at a very special time point, a little bit
later then read_unix_fd() but a little bit sooner than
register_async(), as a result, the async read service in the reader
side has no chance to be noticed about closing of writer any more
because it is already closed.
That's why the reader process waits forever on the async overlapped event.
The solution we worked out is: If the writer is closed, then the
reader register_async() should fail with STATUS_PIPE_BROKEN
immediately, so the reader won't try to call WaitForSingleObject on
the async overlapped event at all.
Patch from Sebastian Lackner:
Subject: server: Do not allow to queue async operation for broken pipes.
We've tested this patches for a couple of weeks, and it has been
confirmed working, gcc compiles more than 64 times without any
I'm happy to close this thread, next goal will be other Wine+Cygwin bugs... :)
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple