Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[New msys2-runtime version] 2 new items #5257

Closed
github-actions bot opened this issue Nov 14, 2024 · 1 comment
Closed

[New msys2-runtime version] 2 new items #5257

github-actions bot opened this issue Nov 14, 2024 · 1 comment

Comments

@github-actions
Copy link

[New msys2-runtime version] fixup! cygthread: suspend thread before terminating.

fixup! cygthread: suspend thread before terminating.

Suppress error output if ReadFile on child wait pipe returns
ERROR_OPERATION_ABORTED due to addition of CancelSynchronousIo call.

msys2/msys2-runtime@eafd9a2

[New msys2-runtime version] cygthread: suspend thread before terminating.

cygthread: suspend thread before terminating.

This addresses an extremely difficult to debug deadlock when running
under emulation on ARM64.

A relatively easy way to trigger this bug is to call `fork()`, then within the
child process immediately call another `fork()` and then `exit()` the
intermediate process.

It would seem that there is a "code emulation" lock on the wait thread at
this stage, and if the thread is terminated too early, that lock still exists
albeit without a thread, and nothing moves forward.

It seems that a `SuspendThread()` combined with a `GetThreadContext()`
(to force the thread to _actually_ be suspended, for more details see
https://devblogs.microsoft.com/oldnewthing/20150205-00/?p=44743)
makes sure the thread is "booted" from emulation before it is suspended.

Hopefully this means it won't be holding any locks or otherwise leave
emulation in a bad state when the thread is terminated.

Also, attempt to use `CancelSynchonousIo()` (as seen in `flock.cc`) to avoid
the need for `TerminateThread()` altogether.  This doesn't always work,
however, so was not a complete fix for the deadlock issue.

Addresses: https://cygwin.com/pipermail/cygwin-developers/2024-May/012694.html
Signed-off-by: Jeremy Drake <cygwin@jdrake.com>

msys2/msys2-runtime@e09c64e

@dscho
Copy link
Member

dscho commented Nov 14, 2024

I rolled these into git-for-windows/msys2-runtime#73. Closing this here ticket.

@dscho dscho closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant