coreutils-9.6-1 (TEST): cp: infinite SEEK_SET/DATA/HOLE loop if file is compressed

Christian Franke Christian.Franke@t-online.de
Thu Feb 13 17:15:26 GMT 2025


Testcase:

$ uname -r
3.5.7-1.x86_64

$ cygcheck -f /bin/cp.exe
coreutils-9.6-1

$ for i in 1 2 3; do cat /bin/cygwin1.dll > file$i; done

$ compact /C file2 # NTFS compression
... (1.7 : 1) ...

$ compact /C /EXE:LZX file3 # Compact OS LZX compression
... (2.8 : 1) ...

$ stat -c '%b %s %n' file?
2928 2995253 file1
1720 2995253 file2
1044 2995253 file3

$ cp file1 copy1 # OK

$ cp file2 copy2 # Hangs
...[^C]

$ cp file3 copy3 # Hangs
...[^C]

$ md5sum file? copy?
2954646a9a0fe4579c3fc1f44dd4bb6a *file1
2954646a9a0fe4579c3fc1f44dd4bb6a *file2
2954646a9a0fe4579c3fc1f44dd4bb6a *file3
2954646a9a0fe4579c3fc1f44dd4bb6a *copy1
2954646a9a0fe4579c3fc1f44dd4bb6a *copy2
2954646a9a0fe4579c3fc1f44dd4bb6a *copy3

$ (sleep 2; pskill strace) & strace cp file3 copy3
...
    47 2004141 [main] cp 5546 lseek: 2995253 = lseek(3, 2995253, 0) # 
SEEK_SET
    46 2004187 [main] cp 5546 fhandler_base::lseek: setting file pointer 
to 2995253 # EOF
    47 2004234 [main] cp 5546 lseek: 2995253 = lseek(3, 2995253, 3) # 
SEEK_DATA
    46 2004280 [main] cp 5546 fhandler_base::lseek: setting file pointer 
to 2995253
    47 2004327 [main] cp 5546 lseek: 2995253 = lseek(3, 2995253, 4) # 
SEEK_HOLE
    46 2004373 [main] cp 5546 fhandler_base::lseek: setting file pointer 
to 2995253
    46 2004419 [main] cp 5546 lseek: 2995253 = lseek(3, 2995253, 0)
    51 2004470 [main] cp 5546 fhandler_base::lseek: setting file pointer 
to 2995253
    47 2004517 [main] cp 5546 lseek: 2995253 = lseek(3, 2995253, 3)
    47 2004564 [main] cp 5546 fhandler_base::lseek: setting file pointer 
to 2995253
    47 2004611 [main] cp 5546 lseek: 2995253 = lseek(3, 2995253, 4)
    46 2004657 [main] cp 5546 fhandler_base::lseek: setting file pointer 
to 2995253
Process strace killed.


file1/2 are detected as a possible sparse files but the optimized copy 
algorithm does not properly handle the non-sparse case. Upstream bug?

Similar report for coreutils-9.5-1:
https://sourceware.org/pipermail/cygwin/2025-January/257082.html

-- 
Regards,
Christian



More information about the Cygwin mailing list