public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Chris Roehrig <croehrig@house.org>
To: Ken Brown via Cygwin <cygwin@cygwin.com>
Subject: cat fifo hang [Re: [ANNOUNCEMENT] cygwin 3.3.0-0.2.6c1f49f83fde (TEST)]
Date: Sun, 17 Oct 2021 13:52:35 -0700	[thread overview]
Message-ID: <3734589D-7DB4-41F1-9BE6-AF3A36693397@house.org> (raw)
In-Reply-To: <2c263022-b361-f697-ca7b-5caface23872@cornell.edu>


On Sun Oct 17 2021, at 9:19 AM, Ken Brown via Cygwin <cygwin@cygwin.com> wrote:

> On 10/16/2021 1:42 PM, Chris Roehrig wrote:
>> On Mon Sep 27 2021, at 7:26 AM, Ken Brown via Cygwin <cygwin@cygwin.com> wrote:
>>> On 9/26/2021 8:57 PM, Chris Roehrig wrote:
>>>> I have installed this (completely this time) and have encountered no issues with it.  I'm getting full gigabit speeds with my rsync transfers.   Looks great!
>>> 
>>> Thanks for testing.
>> I've encountered a crash that might be related.   I had previously been having occasional crashes/hangs of cat.exe over the years, but this is the first time I've ever gotten an error message:
>> cygwin error: 0 [fifo_reader] cat 11398 C:\cygwin\bin\cat.exe: *** fatal  error - Can't add a client handler, Win32 error 123
> 
> This isn't a crash in the usual sense.  It's the Cygwin fifo code issuing a fatal error because an attempt to create a new Windows pipe instance failed. And it's in code that's been around for a while, so it's not related to the new pipe implementation.
> 
>> cat here is reading from a fifo created with mkfifo.
>> I've only encountered it once (out of daily runs over the last couple weeks) and don't know how to replicate it.   Possibly a race?    Looks like my script has tried to mitigate this with a sleep 1 between the mkfifo and the fork: cat < $fifo &
> 
> The sleep shouldn't be necessary.  If it is, there's a bug in the fifo code. Can you remove the sleep and see what happens?  It would be great if that made it possible to replicate the problem.

Here's a script that pretty reliably hangs cat after some iterations.    I haven't yet gotten a repeat of that error message though.
It runs fine on Ubuntu 20.04 and Mac OS X 10.8.4.


#!/bin/bash

# take arg as number of iterations (default=100)
STEPS="${1-100}"

FIFO_PFX="/tmp/catfifo_"
FIFO_WAIT=0
STEP_WAIT=0

function mysleep() { if [ -n "$1" -a "$1" != "0" ]; then sleep "$1"; fi }

function cleanup(){
	rm -f "$FIFO_PFX"*
}
trap cleanup EXIT

printf "Creating $STEPS fifo readers...\n"
for ((i=0; i<STEPS; i++ )); do
	fifo="$FIFO_PFX$i"

	# create fifo
	mkfifo "$fifo"
	mysleep $FIFO_WAIT

	# fork a process reading from fifo and writing it to stdout
	cat < "$fifo" &
	pid=$!
	printf "Created PID=$pid  reading from $fifo\n"

	# redirect FD3 to the fifo and print a message to it
	exec 3>"$fifo"		
	printf "FIFO %d\n" "$i" >&3

	# close the file descriptor, wait for process to exit and clean up
	exec 3>&-
	wait $pid
	rm -f "$fifo"

	mysleep $STEP_WAIT
done


  reply	other threads:[~2021-10-17 20:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-25  1:53 [ANNOUNCEMENT] cygwin 3.3.0-0.2.6c1f49f83fde (TEST) Ken Brown via Cygwin-announce
2021-09-27  0:57 ` Chris Roehrig
2021-09-27 14:26   ` Ken Brown
2021-10-16 17:42     ` Chris Roehrig
2021-10-17 16:19       ` Ken Brown
2021-10-17 20:52         ` Chris Roehrig [this message]
2021-10-17 22:15           ` cat fifo hang [Re: [ANNOUNCEMENT] cygwin 3.3.0-0.2.6c1f49f83fde (TEST)] Ken Brown
2021-10-24 21:51             ` Ken Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3734589D-7DB4-41F1-9BE6-AF3A36693397@house.org \
    --to=croehrig@house.org \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).