GNU bug report logs - #52410
"mv -T --backup=numbered hello world/" renameat2 infinite loop

Previous Next

Package: coreutils;

Reported by: Vincent Vermilya <vincentvermilya <at> gmail.com>

Date: Fri, 10 Dec 2021 12:09:02 UTC

Severity: normal

Done: Paul Eggert <eggert <at> cs.ucla.edu>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 52410 in the body.
You can then email your comments to 52410 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#52410; Package coreutils. (Fri, 10 Dec 2021 12:09:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Vincent Vermilya <vincentvermilya <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 10 Dec 2021 12:09:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Vincent Vermilya <vincentvermilya <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: "mv -T --backup=numbered hello world/" renameat2 infinite loop
Date: Fri, 10 Dec 2021 02:22:03 -0800
[Message part 1 (text/plain, inline)]
If DEST directory has a trailing slash in "mv -T --backup=numbered", mv
gets stuck in an infinite loop. This does not happen without the trailing
slash. strace shows renameat2 as the call that gets looped on. This is
tested on coreutils 8.30 Ubuntu 20.04.

Example:
```
mkdir hello hello1 world/
mv -T --backup=numbered hello world/
strace mv -T --backup=numbered hello1 world/ 2>&1 | less
```
less output at infinite loop:
```
renameat2(AT_FDCWD, "world/", 3, "world.~1~", RENAME_NOREPLACE) = -1 EEXIST
(File exists)
lseek(3, 0, SEEK_SET)                   = 0
getdents64(3, /* 39 entries */, 32768)  = 1240
getdents64(3, /* 0 entries */, 32768)   = 0
renameat2(AT_FDCWD, "world/", 3, "world/", RENAME_NOREPLACE) = -1 EEXIST
(File exists)
lseek(3, 0, SEEK_SET)                   = 0
getdents64(3, /* 39 entries */, 32768)  = 1240
getdents64(3, /* 0 entries */, 32768)   = 0
renameat2(AT_FDCWD, "world/", 3, "world/", RENAME_NOREPLACE) = -1 EEXIST
(File exists)
lseek(3, 0, SEEK_SET)                   = 0
getdents64(3, /* 39 entries */, 32768)  = 1240
getdents64(3, /* 0 entries */, 32768)   = 0
```
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#52410; Package coreutils. (Fri, 10 Dec 2021 22:16:02 GMT) Full text and rfc822 format available.

Message #8 received at 52410 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Vincent Vermilya <vincentvermilya <at> gmail.com>
Cc: Gnulib bugs <bug-gnulib <at> gnu.org>, 52410 <at> debbugs.gnu.org
Subject: Re: bug#52410: "mv -T --backup=numbered hello world/" renameat2
 infinite loop
Date: Fri, 10 Dec 2021 14:15:02 -0800
[Message part 1 (text/plain, inline)]
On 12/10/21 02:22, Vincent Vermilya wrote:
> If DEST directory has a trailing slash in "mv -T --backup=numbered", mv
> gets stuck in an infinite loop. This does not happen without the trailing
> slash. strace shows renameat2 as the call that gets looped on.

Thanks for the bug report. This is due to a Gnulib bug, so I'm cc'ing 
bug-gnulib.

I installed the first three attached patches into Gnulib. The first one 
should fix the bug there, and the other two are refactoring cleanups.

I installed the last two attached patches into coreutils to propagate 
this fix into coreutils and add a regression test.
[0001-backupfile-fix-numbered-backups-for-XXX.patch (text/x-patch, attachment)]
[0002-backupfile-prefer-signed-integers.patch (text/x-patch, attachment)]
[0003-backupfile-assume-C99-decls.patch (text/x-patch, attachment)]
[0001-build-update-gnulib-submodule-to-latest.patch (text/x-patch, attachment)]
[0002-mv-Bug-52410-fix.patch (text/x-patch, attachment)]

bug closed, send any further explanations to 52410 <at> debbugs.gnu.org and Vincent Vermilya <vincentvermilya <at> gmail.com> Request was from Paul Eggert <eggert <at> cs.ucla.edu> to control <at> debbugs.gnu.org. (Fri, 28 Jan 2022 01:31:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 25 Feb 2022 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 32 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.