Hi Chet,

On Thu, Sep 18, 2025 at 02:52:13PM -0400, Chet Ramey wrote:
> On 9/17/25 3:39 PM, Bruno Haible via Bug reports for the GNU Bourne Again
> SHell wrote:
>
> > Machine Type: x86_64-pc-cygwin
> >
> > Bash Version: 5.2
> > Patch Level: 21
> > Release Status: release
> >
> > Description:
> > ============
> >
> > bash hangs when executing a very particular config.status script.
> >
> > Repeat-By:
> > ==========
> >
> > ./config.status
> >
> > or
> >
> > sh -x ./config.status 2>&1 | tee config.status.xlog
>
> I cannot reproduce this on RHEL or macOS using both bash-5.2.37 and
> bash-5.3.3. I don't have or use cygwin; I recommend you open a bug
> report with the Cygwin developers.
>

I'm not a Cygwin developer but looked into this anyway, arriving at the attached
patch.

There's a TL;DR discussion of this patch starting at
https://cygwin.com/pipermail/cygwin/2025-October/258857.html

Here's the first bit (edited with hindsight):-
> This only affects here documents over 64KB by 128 bytes or less.
> The underlying cause is a bug in Windows which damages the build process.
>
> Bash tries to send here document data to the target via a pipe.
> It has to write the entire document to the pipe before any of it get read.
> Bash checks that the system it's running on can accept that much data
> in a pipe, otherwise bash uses a temporary file.
>
> In redir.c, bash first checks that the here document is smaller than the pipe
> capacity calculated at build time. This value is wrong because of the bug.

And here's the last bit of the last email in the series:
> io.Information has changed from 0 to 128 without the watchpoint triggering.
>
> (Not shown) I did set breakpoints in all the other threads to report if any of
> them woke up. None did.
>
> Another process (perhaps an svchost?) modified the return from write().
> Nothing cygwin or bash can do about that. Hence my suggested fix.

Patch is against GNU bash, version 5.3.0(1)-maint[044c1acc].

Cheers ... Duncan.
diff --git a/builtins/psize.c b/builtins/psize.c
index d499a1de..82bcca12 100644
--- a/builtins/psize.c
+++ b/builtins/psize.c
@@ -50,7 +50,11 @@ int nw;
 sighandler
 sigpipe (int sig)
 {
+#ifdef __CYGWIN__
+  fprintf (stderr, "%d\n", nw - 128);
+#else
   fprintf (stderr, "%d\n", nw);
+#endif
   exit (0);
 }
 

Reply via email to