DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 54GKuTqI023208 Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 54GKuTqI023208 Authentication-Results: delorie.com; dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=Mh6mlnUZ X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 07DA9385C411 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1747428988; bh=4WGihbj5D1QLs7gdRlBWwVM6+n1rB4lCFGyb8pEeDAs=; h=Date:To:Subject:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Mh6mlnUZsB7lxbsu5u07EzoI+8ax1eJrCPkBgctV1tmHMd57pRziVDIBsAgpHlNjM o7TQhWtYOuX0pu49ru6XW5q7SXDtfLLQnvp1WylyqQxHIS41hHmOXeA0Sn+toPfLkT 5zfyqaLroU2toX5nINtahYRkWVjwyP8uJO1j7Juw= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A72023858416 ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A72023858416 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747428961; cv=none; b=m1JukXxQ3SRFmTov5a1WeR24k0qDFkO8nBQEl0xmKtRH35vCP8YQ51K5gBzI7yn6/R6+UDmIWb8sQodRmLrfG/rjLVDlxL9haDvt+Ja9BsRlsFGmIcIwbKXT0rguj7w5Oe2dJN/S90IKQCMSoiPb96xkA6QaGk34I4UA55ODwn4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747428961; c=relaxed/simple; bh=lfYUe81XQuD02roI6fHIegmsaN5i9+e73L5bjfZYL70=; h=Date:From:To:Subject:Message-Id:Mime-Version:DKIM-Signature; b=oJN/TNDglZd0edlLVNRkk5pK5iU6y5hRsSfOQ5M9rpMaxDTiTIpR4+99c/h6EagJQ8SalbirvXjbYuYNWtKn/ex5vUFpMZs4KlDB7CwMNahow7Kk8qRWk80D/+Dn0xq4l4/QUQkM0fcq72ACsLT/PV8k1OnMEzeTv6SqCx+ljjc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A72023858416 Date: Sat, 17 May 2025 05:55:55 +0900 To: cygwin AT cygwin DOT com Subject: Re: FIFO hangs (Probably a bug of cygwin fifo) Message-Id: <20250517055555.02f6adfd9670552531c1dd6e@nifty.ne.jp> In-Reply-To: References: <20250514182934 DOT ee8ff6c46ecfc44c69e70b72 AT nifty DOT ne DOT jp> <20250516084640 DOT 2b20feda1c8f65cddbd264bc AT nifty DOT ne DOT jp> <20250516175923 DOT 680fc55b6aa2c3cd9d83199d AT nifty DOT ne DOT jp> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32) Mime-Version: 1.0 X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Takashi Yano via Cygwin Reply-To: Takashi Yano Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com Sender: "Cygwin" On Fri, 16 May 2025 15:08:16 -0400 Ken Brown wrote: > On 5/16/2025 4:59 AM, Takashi Yano via Cygwin wrote: > > On Fri, 16 May 2025 08:46:40 +0900 > > Takashi Yano wrote: > >> diff --git a/winsup/cygwin/local_includes/cygheap.h b/winsup/cygwin/local_includes/cygheap.h > >> index fed87ec2b..7d11fbb37 100644 > >> --- a/winsup/cygwin/local_includes/cygheap.h > >> +++ b/winsup/cygwin/local_includes/cygheap.h > >> @@ -604,6 +604,8 @@ class cygheap_fdnew : public cygheap_fdmanip > >> { > >> if (cygheap->fdtab[fd]) > >> cygheap->fdtab[fd]->inc_refcnt (); > >> + if (locked) > >> + cygheap->fdtab.unlock (); > >> } > >> void operator = (fhandler_base *fh) {cygheap->fdtab[fd] = fh;} > >> }; > > > > This should not be done, because the parent class cygheap_fdmanip > > does that. > Right. But the other part of the patch (to syscalls.cc) looks right to > me, and I agree that it fixes the hang. Here's my understanding of why > it works: The main thread tries to open the fifo for reading, but > fhandler_fifo::open blocks until it detects that someone is opening the > fifo for writing. The other thread wants to do that, but it never gets > to the point of calling fhandler_fifo::open because it is stuck waiting > for the lock on cygheap->fdtab. To fix this, we need to delay the > construction of the cygheap_fdnew object fd until after > fhandler_fifo::open has been called. > > Do you agree with this explanation, or is there something else going on? > In either case, I think it would be good to include at least a brief > explanation in your commit message, since this is a pretty subtle bug. > And thanks for finding the fix! Thank you for confirming. I agree whth your explanation. I'd apply the patch with above explanation. Thanks! -- Takashi Yano -- 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