Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zstd won't remove the file after compression unless --rm is last argument #3719

Closed
okias opened this issue Aug 12, 2023 · 10 comments · Fixed by #3942
Closed

zstd won't remove the file after compression unless --rm is last argument #3719

okias opened this issue Aug 12, 2023 · 10 comments · Fixed by #3942
Assignees
Labels
release-blocking Must be done by the release

Comments

@okias
Copy link

okias commented Aug 12, 2023

Describe the bug
zstd won't remove the file after compression when --rm argument is passed.

To Reproduce
Steps to reproduce the behavior:

  1. zstd --rm -f -T0 -8qc dir/file -o dir/file.zst
  2. ls dir/file
  3. file is still present

If --rm is placed as a last argument, for example zstd -T0 -8qc --rm dir/file -o dir/file.zst, removal works as expected.

Expected behavior
File is removed even when --rm is not last argument.

Desktop (please complete the following information):

  • OS: Debian 12 (bookworm) and Debian 13 (trixie)
  • Version 1.5.4+dfsg2-5 and 1.5.5+dfsg2-1
@Cyan4973
Copy link
Contributor

Cyan4973 commented Aug 12, 2023

I just make the exact same test as described in the issue:
dir/file was properly removed after zstd operation.
It worked even when file was in read-only mode.

There might be some other context information required to reproduce the issue.
For example, maybe some specific access permission scenario.

@Cyan4973 Cyan4973 self-assigned this Aug 12, 2023
@okias
Copy link
Author

okias commented Aug 12, 2023

we have this issue in CI (Debian 12) and on my local machine (Debian 13) too. Thinking where could be difference.

@okias
Copy link
Author

okias commented Aug 12, 2023

Full strace (run in tmpfs, previously on ext4, so no difference either)

$ strace zstd --rm -f -T0 -8qc dir/file -o dir/file.zst
execve("/usr/bin/zstd", ["zstd", "--rm", "-f", "-T0", "-8qc", "dir/file", "-o", "dir/file.zst"], 0x7fff5ff11dc8 /* 62 vars */) = 0
brk(NULL)                               = 0x55cddcea5000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801fd68000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=123730, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 123730, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f801fd49000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=121280, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 123280, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f801fd2a000
mmap(0x7f801fd2d000, 77824, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7f801fd2d000
mmap(0x7f801fd40000, 28672, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0x7f801fd40000
mmap(0x7f801fd47000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c000) = 0x7f801fd47000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblzma.so.5", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=190456, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 188440, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f801fcfb000
mmap(0x7f801fcff000, 118784, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0x7f801fcff000
mmap(0x7f801fd1c000, 49152, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x21000) = 0x7f801fd1c000
mmap(0x7f801fd28000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2d000) = 0x7f801fd28000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/liblz4.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\0\0\0\0\0\0\0"..., 832) = 832
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=149952, ...}, AT_EMPTY_PATH) = 0
mmap(NULL, 152032, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f801fcd5000
mmap(0x7f801fcd8000, 122880, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x3000) = 0x7f801fcd8000
mmap(0x7f801fcf6000, 12288, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x21000) = 0x7f801fcf6000
mmap(0x7f801fcf9000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x23000) = 0x7f801fcf9000
close(3)                                = 0
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220x\2\0\0\0\0\0"..., 832) = 832
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
newfstatat(3, "", {st_mode=S_IFREG|0755, st_size=1926256, ...}, AT_EMPTY_PATH) = 0
pread64(3, "\6\0\0\0\4\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0@\0\0\0\0\0\0\0"..., 784, 64) = 784
mmap(NULL, 1974096, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f801faf3000
mmap(0x7f801fb19000, 1396736, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x26000) = 0x7f801fb19000
mmap(0x7f801fc6e000, 344064, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x17b000) = 0x7f801fc6e000
mmap(0x7f801fcc2000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1cf000) = 0x7f801fcc2000
mmap(0x7f801fcc8000, 53072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f801fcc8000
close(3)                                = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801faf1000
arch_prctl(ARCH_SET_FS, 0x7f801faf2040) = 0
set_tid_address(0x7f801faf2310)         = 353985
set_robust_list(0x7f801faf2320, 24)     = 0
rseq(0x7f801faf2960, 0x20, 0, 0x53053053) = 0
mprotect(0x7f801fcc2000, 16384, PROT_READ) = 0
mprotect(0x7f801fcf9000, 4096, PROT_READ) = 0
mprotect(0x7f801fd28000, 4096, PROT_READ) = 0
mprotect(0x7f801fd47000, 4096, PROT_READ) = 0
mprotect(0x55cddbf64000, 4096, PROT_READ) = 0
mprotect(0x7f801fd9a000, 8192, PROT_READ) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
munmap(0x7f801fd49000, 123730)          = 0
getrandom("\x76\x42\xde\x24\xfa\x41\x2b\x18", 8, GRND_NONBLOCK) = 8
brk(NULL)                               = 0x55cddcea5000
brk(0x55cddcec6000)                     = 0x55cddcec6000
rt_sigaction(SIGABRT, {sa_handler=0x55cddbf17b70, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000, sa_restorer=0x7f801fb2f510}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGFPE, {sa_handler=0x55cddbf17b70, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000, sa_restorer=0x7f801fb2f510}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGILL, {sa_handler=0x55cddbf17b70, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000, sa_restorer=0x7f801fb2f510}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGSEGV, {sa_handler=0x55cddbf17b70, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000, sa_restorer=0x7f801fb2f510}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGBUS, {sa_handler=0x55cddbf17b70, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000, sa_restorer=0x7f801fb2f510}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
openat(AT_FDCWD, "/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC) = 3
read(3, "0-7\n", 1024)                  = 4
close(3)                                = 0
openat(AT_FDCWD, "/proc/cpuinfo", O_RDONLY) = 3
newfstatat(3, "", {st_mode=S_IFREG|0444, st_size=0, ...}, AT_EMPTY_PATH) = 0
read(3, "processor\t: 0\nvendor_id\t: Genuin"..., 1024) = 1024
read(3, "clflushopt clwb intel_pt avx512c"..., 1024) = 1024
read(3, "\ncore id\t\t: 1\ncpu cores\t: 4\napic"..., 1024) = 1024
read(3, "fni vaes vpclmulqdq avx512_vnni "..., 1024) = 1024
read(3, " sse2 ss ht tm pbe syscall nx pd"..., 1024) = 1024
read(3, "d ept_1gb flexpriority apicv tsc"..., 1024) = 1024
read(3, "xtpr pdcm pcid sse4_1 sse4_2 x2a"..., 1024) = 1024
read(3, "5990.40\nclflush size\t: 64\ncache_"..., 1024) = 1024
read(3, " vpid ept_ad fsgsbase tsc_adjust"..., 1024) = 1024
read(3, "185G7 @ 3.00GHz\nstepping\t: 1\nmic"..., 1024) = 1024
read(3, "erm ida arat pln pts hwp hwp_not"..., 1024) = 1024
read(3, ": yes\nflags\t\t: fpu vme de pse ts"..., 1024) = 1024
read(3, "sect md_clear ibt flush_l1d arch"..., 1024) = 1024
read(3, "nonstop_tsc cpuid aperfmperf tsc"..., 1024) = 1024
read(3, "s pml ept_mode_based_exec tsc_sc"..., 1024) = 232
read(3, "", 1024)                       = 0
close(3)                                = 0
ioctl(2, TCGETS, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
newfstatat(AT_FDCWD, "dir/file", {st_mode=S_IFREG|0644, st_size=0, ...}, 0) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f801fb78950, sa_mask=[], sa_flags=SA_RESTORER|SA_ONSTACK|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f801fb2f510}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f801f2f0000
mprotect(0x7f801f2f1000, 8388608, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[], [], 8)   = 0
clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, child_tid=0x7f801faf0990, parent_tid=0x7f801faf0990, exit_signal=0, stack=0x7f801f2f0000, stack_size=0x7fff80, tls=0x7f801faf06c0} => {parent_tid=[353986]}, 88) = 353986
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f2cf000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f2ae000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f28d000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f26c000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f24b000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f22a000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f209000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f1e8000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f1c7000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801f1a6000
mmap(NULL, 8392704, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f801e9a5000
mprotect(0x7f801e9a6000, 8388608, PROT_READ|PROT_WRITE) = 0
rt_sigprocmask(SIG_BLOCK, ~[], [], 8)   = 0
clone3({flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, child_tid=0x7f801f1a5990, parent_tid=0x7f801f1a5990, exit_signal=0, stack=0x7f801e9a5000, stack_size=0x7fff80, tls=0x7f801f1a56c0} => {parent_tid=[353987]}, 88) = 353987
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e984000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e963000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e942000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e921000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e900000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e8df000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e8be000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e89d000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e87c000
mmap(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e85b000
mmap(NULL, 266240, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f801e81a000
newfstatat(AT_FDCWD, "dir/file", {st_mode=S_IFREG|0644, st_size=0, ...}, 0) = 0
newfstatat(AT_FDCWD, "dir/file", {st_mode=S_IFREG|0644, st_size=0, ...}, 0) = 0
openat(AT_FDCWD, "dir/file", O_RDONLY)  = 3
newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=0, ...}, AT_EMPTY_PATH) = 0
read(3, "", 131072)                     = 0
newfstatat(AT_FDCWD, "dir/file", {st_mode=S_IFREG|0644, st_size=0, ...}, 0) = 0
newfstatat(AT_FDCWD, "dir/file.zst", 0x7ffc9a07d9d0, 0) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "dir/file.zst", 0x7ffc9a07d9f0, 0) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "dir/file.zst", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 4
fcntl(4, F_GETFL)                       = 0x8001 (flags O_WRONLY|O_LARGEFILE)
newfstatat(4, "", {st_mode=S_IFREG|0600, st_size=0, ...}, AT_EMPTY_PATH) = 0
newfstatat(AT_FDCWD, "dir/file.zst", {st_mode=S_IFREG|0600, st_size=0, ...}, 0) = 0
rt_sigaction(SIGINT, {sa_handler=0x55cddbf18940, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000, sa_restorer=0x7f801fb2f510}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, {tv_sec=0, tv_nsec=3431821}) = 0
newfstatat(AT_FDCWD, "dir/file", {st_mode=S_IFREG|0644, st_size=0, ...}, 0) = 0
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, {tv_sec=0, tv_nsec=3467925}) = 0
rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_INTERRUPT|SA_NODEFER|SA_RESETHAND|0xffffffff00000000, sa_restorer=0x7f801fb2f510}, {sa_handler=0x55cddbf18940, sa_mask=[], sa_flags=SA_RESTORER|SA_NODEFER|SA_RESETHAND, sa_restorer=0x7f801fb2f510}, 8) = 0
newfstatat(4, "", {st_mode=S_IFREG|0600, st_size=0, ...}, AT_EMPTY_PATH) = 0
fchown(4, -1, 1000)                     = 0
fchmod(4, 0644)                         = 0
fchown(4, 1000, -1)                     = 0
write(4, "(\265/\375$\0\1\0\0\231\351\330Q", 13) = 13
close(4)                                = 0
utimensat(AT_FDCWD, "dir/file.zst", [UTIME_NOW, {tv_sec=1691859345, tv_nsec=36018189} /* 2023-08-12T18:55:45.036018189+0200 */], 0) = 0
close(3)                                = 0
futex(0x55cddcea7178, FUTEX_WAKE_PRIVATE, 2147483647) = 1
futex(0x7f801faf0990, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 353986, NULL, FUTEX_BITSET_MATCH_ANY) = 0
munmap(0x7f801f2cf000, 135168)          = 0
munmap(0x7f801f2ae000, 135168)          = 0
munmap(0x7f801f28d000, 135168)          = 0
munmap(0x7f801f26c000, 135168)          = 0
munmap(0x7f801f24b000, 135168)          = 0
munmap(0x7f801f22a000, 135168)          = 0
munmap(0x7f801f209000, 135168)          = 0
munmap(0x7f801f1e8000, 135168)          = 0
munmap(0x7f801f1c7000, 135168)          = 0
munmap(0x7f801f1a6000, 135168)          = 0
futex(0x55cddcea7878, FUTEX_WAKE_PRIVATE, 2147483647) = 1
futex(0x7f801f1a5990, FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, 353987, NULL, FUTEX_BITSET_MATCH_ANY) = -1 EAGAIN (Resource temporarily unavailable)
munmap(0x7f801e984000, 135168)          = 0
munmap(0x7f801e963000, 135168)          = 0
munmap(0x7f801e942000, 135168)          = 0
munmap(0x7f801e921000, 135168)          = 0
munmap(0x7f801e900000, 135168)          = 0
munmap(0x7f801e8df000, 135168)          = 0
munmap(0x7f801e87c000, 135168)          = 0
munmap(0x7f801e89d000, 135168)          = 0
munmap(0x7f801e8be000, 135168)          = 0
munmap(0x7f801e85b000, 135168)          = 0
munmap(0x7f801e81a000, 266240)          = 0
exit_group(0)                           = ?
+++ exited with 0 +++

edit: I don't see anywhere zstd trying to remove the file :(

@okias
Copy link
Author

okias commented Aug 12, 2023

Found out the issue. When you change

-zstd --rm -8qc dir/file -o dir/file.zst
+zstd -8qc --rm dir/file -o dir/file.zst

So the --rm has to be last argument for it to work.

edit: looking at strace, also unlink("dir/file") = 0 is present :)

@okias okias changed the title zstd won't remove the file after compression zstd won't remove the file after compression unless --rm is last argument Aug 12, 2023
@Cyan4973
Copy link
Contributor

Cyan4973 commented Aug 12, 2023

Strange thing is, I've been using --rm as the first command in my test, and it worked fine !

Note that I'm currently on macos though...

@Cyan4973
Copy link
Contributor

Cyan4973 commented Aug 12, 2023

Also, it seems weird to me seeing -c command used in combination with -o.

-c is supposed to mean "output to stdout".
Sure, it can be combined with > redirection, but
if you just want to send the processed output into a specific file, -o alone is enough.

@okias
Copy link
Author

okias commented Aug 12, 2023

That's a good point, I didn't wrote the command, I just noticed it doesn't do what is expected. Then This command is silently ignored if output is stdout. note in manual pages make sense. Thou would be probably nice to throw some error when combining -c and -o I guess

@Cyan4973
Copy link
Contributor

Cyan4973 commented Aug 12, 2023

Yes, this is an unexpected combination.
As a consequence, I think it has not been tested, nor even defined.

It would be a good thing to fix this for next release.

@okias
Copy link
Author

okias commented Aug 12, 2023

Btw. yeah, changing -8qc to -8q (effectivelly dropping -c) resolve this issue. Do you want this keep open for possible -c vs -o fix?

@Cyan4973
Copy link
Contributor

Btw. yeah, changing -8qc to -8q (effectivelly dropping -c) resolve this issue. Do you want this keep open for possible -c vs -o fix?

Yes, let's keep it open.

PedroHLC pushed a commit to chaotic-cx/mesa-mirror that referenced this issue Aug 12, 2023
Arguments are parsed in order, so the `-c` here causes that first `--rm`
won't get applied and then it gets overriden by `-o` which writes the file.

Sadly zstd won't report this as a issue, but that's being reported in [1],
so maybe in future versions zstd will warn about it.

[1] facebook/zstd#3719

Fixes: d110299 ("ci/deqp-runner: compress results.csv before uploading it to GitLab")

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24651>
Chaotic-Temeraire pushed a commit to chaotic-cx/mesa-mirror that referenced this issue Aug 16, 2023
Arguments are parsed in order, so the `-c` here causes that first `--rm`
won't get applied and then it gets overriden by `-o` which writes the file.

Sadly zstd won't report this as a issue, but that's being reported in [1],
so maybe in future versions zstd will warn about it.

[1] facebook/zstd#3719

Fixes: d110299 ("ci/deqp-runner: compress results.csv before uploading it to GitLab")

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24651>
(cherry picked from commit 9bf104f)
Chaotic-Temeraire pushed a commit to chaotic-cx/mesa-mirror that referenced this issue Sep 1, 2023
Arguments are parsed in order, so the `-c` here causes that first `--rm`
won't get applied and then it gets overriden by `-o` which writes the file.

Sadly zstd won't report this as a issue, but that's being reported in [1],
so maybe in future versions zstd will warn about it.

[1] facebook/zstd#3719

Fixes: d110299 ("ci/deqp-runner: compress results.csv before uploading it to GitLab")

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24651>
(cherry picked from commit 9bf104f)
Chaotic-Temeraire pushed a commit to chaotic-cx/mesa-mirror that referenced this issue Sep 21, 2023
Arguments are parsed in order, so the `-c` here causes that first `--rm`
won't get applied and then it gets overriden by `-o` which writes the file.

Sadly zstd won't report this as a issue, but that's being reported in [1],
so maybe in future versions zstd will warn about it.

[1] facebook/zstd#3719

Fixes: d110299 ("ci/deqp-runner: compress results.csv before uploading it to GitLab")

Signed-off-by: David Heidelberg <david.heidelberg@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24651>
(cherry picked from commit 9bf104f)
@Cyan4973 Cyan4973 added the release-blocking Must be done by the release label Oct 19, 2023
Cyan4973 added a commit that referenced this issue Mar 11, 2024
only disable `--rm` at end of command line parsing,
so that `-c` only disables `--rm` if it's effectively selected,
and not if it's overriden by a later `-o FILE` command.
Cyan4973 added a commit that referenced this issue Mar 12, 2024
Fix #3719 : mixing -c, -o and --rm
hswong3i pushed a commit to alvistack/facebook-zstd that referenced this issue Mar 27, 2024
only disable `--rm` at end of command line parsing,
so that `-c` only disables `--rm` if it's effectively selected,
and not if it's overriden by a later `-o FILE` command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-blocking Must be done by the release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants