On Wed, 20 Nov 2024, Jeremy Drake via Cygwin-patches wrote:

> On Wed, 20 Nov 2024, Corinna Vinschen wrote:
>
> > Patch pushed.
>
> Thanks, folks on ARM64 will be very happy to see that deadlock gone.
> MSYS2 already made a release based on v2 of the patch, and Git for Windows
> at least merged that version of the patch too, and is looking forward to
> making a release with it.

Uh oh, MSYS2 is getting some reports of deadlock/hangs in similar
scenarios on native x86_64 now.  See starting at
https://github.com/msys2/MSYS2-packages/issues/4340#issuecomment-2491401847
if you're interested.

I was able to reproduce, debug, and found the following:

wait_thread is happily waiting in ReadFile, while the main thread is
hanging in ForceCloseHandle1 (close_h, rd_proc_pipe);. The pinfo::release
call is after the wait thread should have been terminated, so it's
apparent the CancelSynchronousIo didn't work for whatever reason (possibly
due to canceling some other sychronous IO, letting it come back around in
the loop and call ReadFile again.

Using gdb to call CancelSynchronousIo again resulted in the wait thread
exiting immediately.


Either we just revert the CancelSynchronousIo part of the patch (the
SuspendThread/GetThreadContext part is what actually solved the ARM64
deadlock), or possibly we can add a flag that the thread should be
shutting down, and check that in the for loop condition in the wait
thread.  Thoughts either way?

Reply via email to