On Mon, Nov 2, 2015 at 10:30 PM, Corinna Vinschen <corinna-cyg...@cygwin.com> wrote: > 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 [1]. ;) > 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. https://github.com/wine-compholio/wine-staging/commit/7b40b6922a0c7a93ff62b69dd2b3c2a6076be851 We've tested this patches for a couple of weeks, and it has been confirmed working, gcc compiles more than 64 times without any hanging! I'm happy to close this thread, next goal will be other Wine+Cygwin bugs... :) [1] http://disney.wikia.com/wiki/Flash -- Regards, Qian Hong - http://www.winehq.org -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple