Re: [PATCH v2] Cygwin: open: Unlock fdtab before open_with_arch()

Takashi Yano <[email protected]> Wed, 22 Jul 2026 21:56:41 +0900
Newsgroups gmane.os.cygwin.patches
Message-ID <[email protected]>
On Wed, 22 Jul 2026 20:10:12 +0900
Takashi Yano wrote:
> Hi Johannes,
> 
> Thanks for reviewing!
> 
> On Tue, 21 Jul 2026 19:16:11 +0200 (CEST)
> Johannes Schindelin wrote:
> > This is the first point where the slot and its reference count agree
> > again; Too late for anything that looked in between. And the cleanup only
> > runs for non-negative descriptors, so it never covers the case above.
> > 
> > Since it is already in `master`, a follow-up patch probably makes most
> > sense. Two things to fix: release the lock when no descriptor is
> > available, and stop a reserved-but-not-yet-open descriptor from looking
> > like a fully open one to the rest of the fdtable. Reviving the old integer
> > marker would mean teaching every consumer of the table about it, so it is
> > not a drop-in.
> 
> Ah, I got it. The user program cannot know that, but cygwin1.dll can
> refere fdtab inside it. What about adding reserved flag to fdtab?

I tried it as quick experiment.

The result of the first reproducer is:
baseline close(-1): result=-1 errno=9
descriptor allocation stopped after 3197 opens: errno=24
second-thread close(-1): result=-1 errno=9

The result of the second reproducer is:
expected FIFO writer descriptor: 4
provisional descriptor query: result=-1 writer_done=0

Are these results as you expected?

-- 
Takashi Yano <[email protected]>