On Wed, 15 Jul 2026 11:20:29 +0000
kikairoya wrote:
> Hello,
> 
> After upgrading to Cygwin 3.6.10, opening a fifo endpoint causes a 
> deadlock.
> (Found in the LLVM testsuite, 
> llvm/unittests/Analysis/MLModelRunnerTest.cpp: 
> InteractiveModelRunner::Evaluation).
> 
> 
> reproducer:
> 
> $ gcc fifotest.c && ./a
> trying to open /tmp/thetestfifo.pipe for write
> trying to open /tmp/thetestfifo.pipe for read
> (hangs here, and some of runs ignore Ctrl+C)
> 
> Opening a fifo is blocked correctly until another endpoint is opened.
> However, Cygwin 3.6.10 never returns, even after both endpoints are 
> requested to be opened.
> 
> Downgrading to Cygwin 3.6.9 results in successful runs:
> 
> $ gcc fifotest.c && ./a
> trying to open /tmp/thetestfifo.pipe for write
> trying to open /tmp/thetestfifo.pipe for read
> wr = 3
> rd = 4
> 
> 
> fifotest.c:
> 
> #include <fcntl.h>
> #include <unistd.h>
> #include <stdio.h>
> #include <pthread.h>
> 
> const char *name = "/tmp/thetestfifo.pipe";
> 
> void *bg() {
>      printf("trying to open %s for read\n", name);
>      int rd = open(name, O_RDONLY);
>      printf("rd = %d\n", rd);
>      close(rd);
>      return 0;
> }
> 
> int main() {
>      mkfifo(name, 0666);
> 
>      pthread_t thr;
>      pthread_create(&thr, 0, bg, 0);
> 
>      printf("trying to open %s for write\n", name);
>      int wr = open(name, O_WRONLY);
>      printf("wr = %d\n", wr);
>      close(wr);
> 
>      void *thret;
>      pthread_join(thr, &thret);
> 
>      unlink(name);
> }

Thanks for the report. I could reproduce the issue and found the culprit.

commit 31bf91f867c5fadd7deb408cf06fe3af8e86bb74
Author: Mark Geisert <[email protected]>
Date:   Wed May 27 22:42:44 2026 -0700

    Cygwin: Ensure unused fd available for open()

    The existing logic for open() assumes an fd is always available in
    the fdtable for a created file.  This leads to a situation where, if
    there is no fd available due to the OPEN_MAX limit being hit, the
    file is created but cannot be referenced by a Cygwin fd.

    Move the fd reservation code to an earlier location within open().

    Reported-by: Christian Franke <[email protected]>
    Addresses: https://cygwin.com/pipermail/cygwin/2026-May/259664.html
    Signed-off-by: Mark Geisert <[email protected]>
    Fixes: e859706578ba (* autoload.cc (NtCreateFile): Add.)

Mark, could you please have a look?

-- 
Takashi Yano <[email protected]>

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

Reply via email to