Skip to content

Avoid deadlock with app execution aliases - #145

Merged
dscho merged 1 commit into
mainfrom
avoid-hang-with-app-execution-aliases
Sep 28, 2026
Merged

dscho merged 1 commit into
mainfrom
avoid-hang-with-app-execution-aliases

Conversation

@dscho

@dscho dscho commented Sep 28, 2026

Copy link
Copy Markdown
Member

msys2/msys2-runtime#372 reports a problem where calling applications via app execution aliases (which Microsoft Store likes to use) would cause infinite hangs of the shell. Let's hot-fix this, as it's a bug that I introduced into Git for Windows' fork of the MSYS2 runtime only two days ago...

Calling `winget.exe` through its app execution alias from an interactive
MSYS2 shell can leave the shell hanging after `winget.exe` exits. This
affects all app execution aliases, not only `winget.exe`.

App execution alias handling was introduced in 0631c66 (Cygwin: Treat
Windows Store's "app execution aliases" as symbolic links, 2021-03-22),
and 6c3d269 (Cygwin: termios: Handle app execution alias in
is_console_app(), 2025-12-10) taught `is_console_app()` to follow
aliases using another `path_conv`, which allocates cygheap memory.

618eb90 (Cygwin: console: Fix undesired mode change at exit of
non-cygwin apps, 2026-09-19) added a second `is_console_app()` call from
`wait_for_resume_if_necessary()`. Unfortunately, at that point,
`child_info_spawn::worker()` already holds the non-recursive
`cygheap_protect`, so following an alias tries to acquire the same lock
recursively and deadlocks.

Let's avoid running `is_console_app()` under that lock by instead
classifying the executable _once_, in `spawn_worker::setup()`, before
acquiring the cygheap lock, then cache and reuse the result for both PTY
setup and the post-resume wait.

Addresses: msys2/msys2-runtime#372
Fixes: 618eb90 (Cygwin: console: Fix undesired mode change at exit
 of non-cygwin apps, 2026-09-19)
Signed-off-by: Christoph Reiter <reiter.christoph@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho dscho self-assigned this Sep 28, 2026
@dscho

dscho commented Sep 28, 2026 •

Copy link
Copy Markdown
Member Author

/open pr

The workflow run was started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants