[BACKPORT] Cygwin: open: Unlock fdtab before open_with_arch()#350
Open
lazka wants to merge 1 commit into
Open
Conversation
dscho
approved these changes
Jul 19, 2026
dscho
left a comment
Collaborator
There was a problem hiding this comment.
While I have some (not yet sent) concerns about that patch which will probably require follow-up fixes, it has been pushed to cygwin/master already, and therefore is appropriate to backport as-is.
Since the commit 31bf91f, opening fifo causes a deadlock. This is because, open_with_arch() for fifo can be blocked until the other side of the fifo is opened. The commit 31bf91f moves the creating cygheap_fdnew before open_with_arch() to address the issue: https://cygwin.com/pipermail/cygwin/2026-May/259664.html However, cygheap_fdnew locks fdtab, so open() for the other side of fifo cannot create cygheap_fdnew until fdtab is unlocked. This is the cause of the deadlock. With this patch, fdtab is unlocked before open_with_arch(), but marked as used using tentative fhandler. The summary of open() is as follows. 1) Lock fdtab. 2) Create new fd. 3) Mark fd as used using tentative fhandler. 4) Unlock fdtab. 5) Call open_with_arch(). 6) Set final fhandler to fd. The important point is that create fd before open_with_arch() to address https://cygwin.com/pipermail/cygwin/2026-May/259664.html, but unlock fdtab before open_with_arch() to address https://cygwin.com/pipermail/cygwin/2026-July/259884.html. Fixes: 31bf91f ("Cygwin: Ensure unused fd available for open()") Addresses: https://cygwin.com/pipermail/cygwin/2026-July/259884.html Reported-by: kikairoya <kikairoya@gmail.com> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp> Reviewed-by: Mark Geisert <mark@maxrnd.com> (cherry picked from commit 524d75f)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since the commit 31bf91f, opening fifo causes a deadlock. This is because, open_with_arch() for fifo can be blocked until the other side of the fifo is opened. The commit 31bf91f moves the creating cygheap_fdnew before open_with_arch() to address the issue: https://cygwin.com/pipermail/cygwin/2026-May/259664.html However, cygheap_fdnew locks fdtab, so open() for the other side of fifo cannot create cygheap_fdnew until fdtab is unlocked. This is the cause of the deadlock.
With this patch, fdtab is unlocked before open_with_arch(), but marked as used using tentative fhandler. The summary of open() is as follows.
The important point is that create fd before open_with_arch() to address https://cygwin.com/pipermail/cygwin/2026-May/259664.html, but unlock fdtab before open_with_arch() to address https://cygwin.com/pipermail/cygwin/2026-July/259884.html.
Fixes: 31bf91f ("Cygwin: Ensure unused fd available for open()")
Addresses: https://cygwin.com/pipermail/cygwin/2026-July/259884.html
Reported-by: kikairoya kikairoya@gmail.com
Reviewed-by: Mark Geisert mark@maxrnd.com
(cherry picked from commit 524d75f)