On 2026-11-21 18:33, Brian Inglis wrote:
On 2026-11-19 21:47, Brian Inglis wrote:
On 2026-11-19 18:34, Paul Eggert wrote:
On 2026-11-19 10:34, Brian Inglis wrote:
I could post the full redacted output, or send the unredacted output to your
PM, if it would help.
Thanks, but I think the strace output suffices. The key lines are here:
17000745 50756044 [main] diff 3042635 fhandler_base::read: returning
-1814967408, binary mode
190 50756234 [main] diff 3042635 read: 2479999888 = read(4,
0x6FFAD85B0010, -1814967408)
114 50756348 [main] diff 3042635 read: read(4, 0x6FFB6C2CCBA0, 0) blocking
120 50756468 [main] diff 3042635 fhandler_base::read: returning 0, binary
mode
107 50756575 [main] diff 3042635 read: 0 = read(4, 0x6FFB6C2CCBA0, 0)
The first two lines says diff called read (4, buf, N) which returned, where N
was 2479999888, but strace misinterpreted the 2479999888 as being
-1814967408. The last three lines suggest that diff called read (4, buf, N)
where N was a multiple of 2**32, and strace got confused into thinking that N
== 0, and so did 'read' itself (!).
I filed a bug report against Cygwin <https://cygwin.com/pipermail/
cygwin/2026- November/260246.html> and installed the attached workaround to
diffutils; please give the workaround a try.
Sorry Paul,
We have a problem rebuilding with auto(re)conf (or GCC) upgraded since last
year, wint_t is no longer /need/ed from GCC 14 stddef.h, so the build now fails.
I will have to follow this up with our autoconf (or GCC) maintainers.
I also have a higher priority issue with gettext defaults changing, but nobody
noticed the static libraries defaulted to omitted in the test release, until I
promoted it to current stable.
I have to deal with that first, as it is preventing fixes to base packages.
Then I will circle back to diffutils auto(re)conf (and/or GCC) when the
maintainers provide those updates, and hopefully can rebuild to test your fix.
Hi Paul,
Seems problem may be a gnulib/autoconf bug reporting okay to use wint_t from gcc
14 stddef.h, so reported to bug-gnulib, and build fix for now is to use config
arg "gl_cv_clean_version_stddef=yes", so will try that now.
Thanks Paul,
That seems to work, but your patch, originally from coreutils lib/safe-read.c,
applying to diffutils lib/cmpbuf.c block_read, which does not include (nor even
distribute) lib/sys-limits.h defining SYS_BUFSIZE_MAX:
In file included from
/usr/src/diffutils/diffutils-3.12-1.x86_64/src/diffutils-3.12/lib/minmax.h:39,
from
/usr/src/diffutils/diffutils-3.12-1.x86_64/src/diffutils-3.12/lib/cmpbuf.c:33:
/usr/src/diffutils/diffutils-3.12-1.x86_64/src/diffutils-3.12/lib/cmpbuf.c: In
function 'block_read':
/usr/src/diffutils/diffutils-3.12-1.x86_64/src/diffutils-3.12/lib/cmpbuf.c:50:27:
error: 'SYS_BUFSIZE_MAX' undeclared (first use in this function)
50 | readlim = MIN (readlim, SYS_BUFSIZE_MAX);
| ^~~~~~~~~~~~~~~
/usr/src/diffutils/diffutils-3.12-1.x86_64/src/diffutils-3.12/lib/cmpbuf.c:50:27:
note: each undeclared identifier is reported only once for each function it
appears in
make[2]: *** [Makefile:6685: libdiffutils_a-cmpbuf.o] Error 1
So I created a patch to add coreutils lib/sys-limits.h to diffutils as
lib/sys-limits.h, added #include "sys-limits.h" to cmpbuf.c just before the line
using SYS_BUFSIZE_MAX, and built that successfully (patches attached).
Test results:
ls -Gg $t1 $t0
+ ls -Gg test7 test0
-rw-r--r--+ 1 11070000002 Nov 21 20:24 test0
-rw-r--r--+ 1 11070000002 Nov 21 20:24 test7
wc -lwmcL $t1 $t0
+ wc -lwmcL test7 test0
410000001 410000001 11070000002 11070000002 26 test7
410000001 410000001 11070000002 11070000002 26 test0
820000002 820000002 22140000004 22140000004 26 total
cmp -bl $t1 $t0 # Correctly detects the difference at the final line
+ cmp -bl test7 test0
11070000001 67 7 60 0
# test7 test0 differ: byte 11070000001, line 410000001 is 67 7 60 0
#strace -o $out \
diff -u $t1 $t0
+ diff -u test7 test0
--- test7 2026-11-21 20:24:35.943178600 -0600
+++ test0 2026-11-21 20:24:35.943178600 -0600
@@ -409999998,4 +409999998,4 @@
12345678911234567892123456
12345678911234567892123456
12345678911234567892123456
-7
+0
echo "diff: exit $?"
+ echo diff: exit 1
diff: exit 1
So many thanks for the fixes and pointers allowing us to get this upgraded.
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retrancher but when there is no more to cut
-- Antoine de Saint-Exupéry--- lib/sys-limits.h 2025-01-01 02:32:29.000000000 -0700
+++ lib/sys-limits.h 2025-01-01 02:32:29.000000000 -0700
@@ -0,0 +1,42 @@
+/* System call limits
+
+ Copyright 2018-2025 Free Software Foundation, Inc.
+
+ This file is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ This file is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this program. If not, see <https://www.gnu.org/licenses/>. */
+
+#ifndef _GL_SYS_LIMITS_H
+#define _GL_SYS_LIMITS_H
+
+#include <limits.h>
+
+/* Maximum number of bytes to read or write in a single system call.
+ This can be useful for system calls like sendfile on GNU/Linux,
+ which do not handle more than MAX_RW_COUNT bytes correctly.
+ The Linux kernel MAX_RW_COUNT is at least INT_MAX >> 20 << 20,
+ where the 20 comes from the Hexagon port with 1 MiB pages; use that
+ as an approximation, as the exact value may not be available to us.
+
+ Using this also works around a serious Linux bug before 2.6.16; see
+ <https://bugzilla.redhat.com/show_bug.cgi?id=612839>.
+
+ Using this also works around a Tru64 5.1 bug, where attempting
+ to read INT_MAX bytes fails with errno == EINVAL. See
+ <https://lists.gnu.org/r/bug-gnu-utils/2002-04/msg00010.html>.
+
+ Using this is likely to work around similar bugs in other operating
+ systems. */
+
+enum { SYS_BUFSIZE_MAX = INT_MAX >> 20 << 20 };
+
+#endif
From 39b8459c459fc68e80d1dbce2a9f78d89a9a4dd8 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Thu, 19 Nov 2026 16:25:14 -0800
Subject: [PATCH] diff: work around Cygwin bug with big buffers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Brian Inglis (bug#882273).
* lib/cmpbuf.c (block_read): Don’t ask Cygwin to read more than
SYS_BUFSIZE_MAX bytes at a time.
---
lib/cmpbuf.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/cmpbuf.c b/lib/cmpbuf.c
index d3739b6..f1a0d76 100644
--- a/lib/cmpbuf.c
+++ b/lib/cmpbuf.c
@@ -43,6 +43,13 @@ block_read (int fd, char *buf, idx_t nbytes)
char *bp = buf;
char const *buflim = buf + nbytes;
idx_t readlim = MIN (IDX_MAX, MIN (SSIZE_MAX, SIZE_MAX));
+#ifdef __CYGWIN__
+ /* Cygwin incorrectly truncates read sizes modulo 2**32, and
+ MS-Windows drivers and Cygwin internals are likely to flake out
+ above SYS_BUFSIZE_MAX anyway. */
+ #include "sys-limits.h"
+ readlim = MIN (readlim, SYS_BUFSIZE_MAX);
+#endif
do
{
@@ -54,9 +61,9 @@ block_read (int fd, char *buf, idx_t nbytes)
if (nread == 0)
break;
- /* Accommodate FreeBSD 13, which can't read more than INT_MAX bytes
- when debug.iosize_max_clamp is nonzero. Prefer a power
- of two for the read limit in this case.
+ /* Accommodate macOS, which can't read more than INT_MAX bytes.
+ FreeBSD behaves similarly if debug.iosize_max_clamp is nonzero.
+ Prefer a power of two for the read limit in this case.
Also, work around a bug in Linux kernel 6.3.8 tmpfs,
which fails if the current offset + bytes_to_read exceeds
--
2.56.1