[Bug 271675] cp: Interrupted system call

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 27 May 2023 12:52:13 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=271675

            Bug ID: 271675
           Summary: cp: Interrupted system call
           Product: Base System
           Version: 13.2-STABLE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: rozhuk.im@gmail.com

While using portmaster and /usr/ports/packages mounted via sshfs I got:

===>   Registering installation for py39-attrs-23.1.0 as automatic
Installing py39-attrs-23.1.0...

===>>> Creating a package for new version py39-attrs-23.1.0
cp: /tmp/ports/usr/ports/devel/py-attrs/work-py39/pkg/py39-attrs-23.1.0.pkg:
Interrupted system call

===>>> Package creation of py39-attrs-23.1.0 failed
===>>> Aborting update


66562: wait4(-1,{ EXITED,val=1 },0x0,0x0)        = 66732 (0x104ac)
66562: fstatat(AT_FDCWD,"/bin/cp",{ mode=-r-xr-xr-x
,inode=9134656,size=22168,blksize=32768 },0x0) = 0 (0x0)
66562: execve("/bin/cp",0x80183c300,0x801841008) EJUSTRETURN
66562: mmap(0x0,135168,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) =
34376814592 (0x801049000)
66562: mprotect(0x801046000,4096,PROT_READ)      = 0 (0x0)
66562: issetugid()                               = 0 (0x0)
66562: sigfastblock(0x1,0x801048830)             = 0 (0x0)
66562: open("/etc/libmap.conf",O_RDONLY|O_CLOEXEC,0101140030) = 3 (0x3)
66562: fstat(3,{ mode=-rw-r--r-- ,inode=41907167,size=47,blksize=32768 }) = 0
(0x0)
66562: read(3,"# $FreeBSD$\nincludedir /usr/loc"...,47) = 47 (0x2f)
66562: close(3)                                  = 0 (0x0)
66562:
open("/usr/local/etc/libmap.d",O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC,0165)
= 3 (0x3)
66562: fcntl(3,F_ISUNIONSTACK,0x0)               = 0 (0x0)
66562: getdirentries(3,"\M^TF8\0\0\0\0\0\f\0\0\0\0\0\0\0"...,4096,{ 0x0 }) =
104 (0x68)
66562: open("/usr/local/etc/libmap.d/mesa.conf",O_RDONLY|O_CLOEXEC,0165) = 4
(0x4)
66562: fstat(4,{ mode=-rw-r--r-- ,inode=3688085,size=38,blksize=32768 }) = 0
(0x0)
66562: read(4,"libGLX_indirect.so.0 libGLX_mesa"...,38) = 38 (0x26)
66562: close(4)                                  = 0 (0x0)
66562: getdirentries(3,0x80104e008,4096,{ 0x200 }) = 0 (0x0)
66562: close(3)                                  = 0 (0x0)
66562: open("/var/run/ld-elf.so.hints",O_RDONLY|O_CLOEXEC,0100420156) = 3 (0x3)
66562: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0,\^A\0\0"...,128) = 128 (0x80)
66562: fstat(3,{ mode=-r--r--r-- ,inode=7,size=428,blksize=4096 }) = 0 (0x0)
66562: pread(3,"/lib:/usr/lib:/usr/lib/compat:/u"...,300,0x80) = 300 (0x12c)
66562: close(3)                                  = 0 (0x0)
66562: open("/lib/libc.so.7",O_RDONLY|O_CLOEXEC|O_VERIFY,00) = 3 (0x3)
66562: fstat(3,{ mode=-r--r--r-- ,inode=6730759,size=1933784,blksize=32768 }) =
0 (0x0)
66562: mmap(0x0,4096,PROT_READ,MAP_PRIVATE|MAP_PREFAULT_READ,3,0x0) =
34376949760 (0x80106a000)
66562: mmap(0x0,4182016,PROT_NONE,MAP_GUARD,-1,0x0) = 34376953856 (0x80106b000)
66562:
mmap(0x80106b000,495616,PROT_READ,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE|MAP_PREFAULT_READ,3,0x0)
= 34376953856 (0x80106b000)
66562:
mmap(0x8010e4000,1384448,PROT_READ|PROT_EXEC,MAP_PRIVATE|MAP_FIXED|MAP_NOCORE|MAP_PREFAULT_READ,3,0x78000)
= 34377449472 (0x8010e4000)
66562:
mmap(0x801236000,45056,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_PREFAULT_READ,3,0x1c9000)
= 34378833920 (0x801236000)
66562:
mmap(0x801241000,20480,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_PREFAULT_READ,3,0x1d3000)
= 34378878976 (0x801241000)
66562:
mmap(0x801246000,2236416,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|MAP_ANON,-1,0x0)
= 34378899456 (0x801246000)
66562: munmap(0x80106a000,4096)                  = 0 (0x0)
66562: close(3)                                  = 0 (0x0)
66562: mprotect(0x801236000,40960,PROT_READ)     = 0 (0x0)
66562: mprotect(0x801236000,40960,PROT_READ|PROT_WRITE) = 0 (0x0)
66562: mprotect(0x801236000,40960,PROT_READ)     = 0 (0x0)
66562: readlink("/etc/malloc.conf",0x7fffffffc780,1024) ERR#2 'No such file or
directory'
66562: issetugid()                               = 0 (0x0)
66562:
mmap(0x0,2097152,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(21),-1,0x0)
= 34382807040 (0x801600000)
66562:
mmap(0x0,2097152,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0)
= 34384904192 (0x801800000)
66562:
mmap(0x0,4194304,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(21),-1,0x0)
= 34387001344 (0x801a00000)
66562: sigaction(SIGINFO,{ 0x10247b0 SA_RESTART ss_t },{ SIG_DFL SA_RESTART
ss_t }) = 0 (0x0)
66562:
fstatat(AT_FDCWD,"/usr/ports/packages/All/py39-attrs-23.1.0.pkg",0x7fffffffd9e8,0x0)
ERR#2 'No such file or directory'
66562:
fstatat(AT_FDCWD,"/tmp/ports/usr/ports/devel/py-attrs/work-py39/pkg/py39-attrs-23.1.0.pkg",{
mode=-rw-r--r-- ,inode=252834,size=78040,blksize=4096 },AT_SYMLINK_NOFOLLOW) =
0 (0x0)
66562: umask(0x1ff)                              = 18 (0x12)
66562: umask(0x12)                               = 511 (0x1ff)
66562:
fstatat(AT_FDCWD,"/tmp/ports/usr/ports/devel/py-attrs/work-py39/pkg/py39-attrs-23.1.0.pkg",{
mode=-rw-r--r-- ,inode=252834,size=78040,blksize=4096 },0x0) = 0 (0x0)
66562:
fstatat(AT_FDCWD,"/usr/ports/packages/All/py39-attrs-23.1.0.pkg",0x7fffffffd6e0,0x0)
ERR#2 'No such file or directory'
66562:
openat(AT_FDCWD,"/tmp/ports/usr/ports/devel/py-attrs/work-py39/pkg/py39-attrs-23.1.0.pkg",O_RDONLY,00)
= 3 (0x3)
66562:
openat(AT_FDCWD,"/usr/ports/packages/All/py39-attrs-23.1.0.pkg",O_WRONLY|O_CREAT|O_TRUNC,0100644)
= 4 (0x4)
66562: copy_file_range(0x3,0x0,0x4,0x0,0x7fffffffffffffff,0x0) ERR#4
'Interrupted system call'
66562: write(2,"cp: ",4)                         = 4 (0x4)
66562: write(2,"/tmp/ports/usr/ports/devel/py-at"...,71) = 71 (0x47)
66562: write(2,": ",2)                           = 2 (0x2)
66562: fstatat(AT_FDCWD,"/usr/share/nls/C/libc.cat",0x7fffffffd380,0x0) ERR#2
'No such file or directory'
66562: fstatat(AT_FDCWD,"/usr/share/nls/libc/C",0x7fffffffd380,0x0) ERR#2 'No
such file or directory'
66562: fstatat(AT_FDCWD,"/usr/local/share/nls/C/libc.cat",0x7fffffffd380,0x0)
ERR#2 'No such file or directory'
66562: fstatat(AT_FDCWD,"/usr/local/share/nls/libc/C",0x7fffffffd380,0x0) ERR#2
'No such file or directory'
66562: write(2,"Interrupted system call\n",24)   = 24 (0x18)
66562: close(4)                                  = 0 (0x0)
66562: close(3)                                  = 0 (0x0)
66562: exit(0x1)                                
66562: process exit, rval = 1


Same time:
cp /tmp/ports/usr/ports/devel/py-attrs/work-py39/pkg/py39-attrs-23.1.0.pkg
/usr/ports/packages/All/py39-attrs-23.1.0.pkg
work without error.


My suggestion is that cp should fallback to old copy proc on EINTR, and
probably EINVAL is mistake, at least according to man copy_file_range():
                        if (use_copy_file_range) {
                                wcount = copy_file_range(from_fd, NULL,
                                    to_fd, NULL, SSIZE_MAX, 0);
                                if (wcount < 0 && errno == EINVAL) {
                                        /* Prob a non-seekable FD */
                                        use_copy_file_range = 0;
                                }
                        }
                        if (!use_copy_file_range) {
                                wcount = copy_fallback(from_fd, to_fd);
                        }

-- 
You are receiving this mail because:
You are the assignee for the bug.