Paul Eggert wrote:
> * lib/safe-read.c (safe_rw) [__CYGWIN__]:
> Work around bug in Cygwin up to at least 3.6.12, where
> ‘read’ and ‘write’ sizes lose high-order bits.  See:
> https://cygwin.com/pipermail/cygwin/2026-November/260246.html

Note that Gnulib's safe-read.c had a protection against this bug
until 2004-08-06 [1]. The old code was not trusting read() to do
anything meaningful for count >= 2^31, whereas the new code was
more optimistic and assumed that read() would fail with EINVAL.


Also, maybe we should reduce the max even further than 2^31? In
clisp/src/win32aux.d there is the comment (from 1998):

/* Limit for the size of a buffer we pass to WriteFile() and similar calls.
 Before introducing this, I have seen mem file corruption: The file produced
 by SAVEINITMEM contained wrong data. More exactly, inside a WriteFile()
 block of size about 75 KB, a block of exactly 8192 bytes, starting at
 an odd address, was shifted to the right by 3 bytes, with zeroes inserted
 at the beginning and three bytes shifted out and lost at the end of this
 8KB block. This problem sometimes disappeared spontaneously, sometimes by
 rebooting, and was sometimes 100% reproducible (the faulty block being
 always at the same address).
 This could be a bug in WinNT 3.51 or in the NFS client. In any case, it's
 better to work around it: Don't pass areas larger than 64 KB to WriteFile().
 Similarly for ReadFile() and similar calls, since we don't know exactly
 where the bug sits.
 PS: I know that this was necessary in VMS. But this is Win32, not VMS ... */
#define MAX_IO  32768


Bruno

[1] commit a62be9f4039b4499cfbb76e394cad2259d03fa84




Reply via email to