GNU bug report logs -
#24714
delete-directory race condition
Previous Next
Reported by: Glenn Morris <rgm <at> gnu.org>
Date: Mon, 17 Oct 2016 02:21:01 UTC
Severity: normal
Found in version 25.1
Fixed in version 26.1
Done: Glenn Morris <rgm <at> gnu.org>
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 24714 in the body.
You can then email your comments to 24714 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Mon, 17 Oct 2016 02:21:02 GMT)
Full text and
rfc822 format available.
Message #3 received at submit <at> debbugs.gnu.org (full text, mbox):
Package: emacs
Version: 25.1
On current Debian testing, many tests in package-test.el fail for me with:
Test package-test-update-listing condition:
(file-error "Removing old name" "No such file or directory"
"/tmp/pkg-test-user-dir-27293kBj/gnupg/S.gpg-agent.rstrd")
I believe this is due to a race condition in delete-directory.
Emacs seems to be lacking an equivalent of "rm -rf".
(delete-directory "/tmp/foo")
will fail with "No such file or directory" if a file in /tmp/foo
happen to be deleted by some other process in between the time that
delete-directory calls directory-files and the time it calls delete-file.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Mon, 17 Oct 2016 06:20:01 GMT)
Full text and
rfc822 format available.
Message #6 received at 24714 <at> debbugs.gnu.org (full text, mbox):
> From: Glenn Morris <rgm <at> gnu.org>
> Date: Sun, 16 Oct 2016 22:20:45 -0400
>
> I believe this is due to a race condition in delete-directory.
> Emacs seems to be lacking an equivalent of "rm -rf".
>
> (delete-directory "/tmp/foo")
>
> will fail with "No such file or directory" if a file in /tmp/foo
> happen to be deleted by some other process in between the time that
> delete-directory calls directory-files and the time it calls delete-file.
IMO, delete-directory should simply catch ENOENT errors and ignore
them when it deletes files and subdirectories under the "recursive"
option. Other errors should signal an error as they do now.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Mon, 17 Oct 2016 15:53:02 GMT)
Full text and
rfc822 format available.
Message #9 received at 24714 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii wrote:
>> will fail with "No such file or directory" if a file in /tmp/foo
>> happen to be deleted by some other process in between the time that
>> delete-directory calls directory-files and the time it calls delete-file.
>
> IMO, delete-directory should simply catch ENOENT errors and ignore
> them when it deletes files and subdirectories under the "recursive"
> option.
I don't think that's enough, since a file could equally well be
_created_ by some other process after delete-directory calls directory-files.
Frankly I don't see how Emacs's delete-directory can work reliably as
currently implemented.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Mon, 17 Oct 2016 16:12:02 GMT)
Full text and
rfc822 format available.
Message #12 received at 24714 <at> debbugs.gnu.org (full text, mbox):
> From: Glenn Morris <rgm <at> gnu.org>
> Cc: 24714 <at> debbugs.gnu.org
> Date: Mon, 17 Oct 2016 11:52:31 -0400
>
> Eli Zaretskii wrote:
>
> >> will fail with "No such file or directory" if a file in /tmp/foo
> >> happen to be deleted by some other process in between the time that
> >> delete-directory calls directory-files and the time it calls delete-file.
> >
> > IMO, delete-directory should simply catch ENOENT errors and ignore
> > them when it deletes files and subdirectories under the "recursive"
> > option.
>
> I don't think that's enough, since a file could equally well be
> _created_ by some other process after delete-directory calls directory-files.
It will solve your use case, with files under /tmp, won't it? A
partial solution is better than no solution at all, IMO.
> Frankly I don't see how Emacs's delete-directory can work reliably as
> currently implemented.
Patches to reimplement it are also welcome.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Mon, 17 Oct 2016 17:02:01 GMT)
Full text and
rfc822 format available.
Message #15 received at 24714 <at> debbugs.gnu.org (full text, mbox):
On Okt 17 2016, Glenn Morris <rgm <at> gnu.org> wrote:
> I don't think that's enough, since a file could equally well be
> _created_ by some other process after delete-directory calls directory-files.
That is ok. The operation cannot successfully be completed in this case.
> Frankly I don't see how Emacs's delete-directory can work reliably as
> currently implemented.
A property it shares with any other operation recursing on directories,
in Emacs or elsewhere.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Tue, 18 Oct 2016 16:46:02 GMT)
Full text and
rfc822 format available.
Message #18 received at 24714 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Although I didn't reproduce the bug, I changed delete-directory
according to Eli's suggestion by installing the attached patch into
master. Glenn, can you please try it in your environment?
[0001-delete-directory-no-longer-errors-when-racing.patch (application/x-patch, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Tue, 18 Oct 2016 16:51:01 GMT)
Full text and
rfc822 format available.
Message #21 received at 24714 <at> debbugs.gnu.org (full text, mbox):
Andreas Schwab wrote:
> That is ok. The operation cannot successfully be completed in this case.
>
>> Frankly I don't see how Emacs's delete-directory can work reliably as
>> currently implemented.
>
> A property it shares with any other operation recursing on directories,
> in Emacs or elsewhere.
That's interesting. I'd assumed there was a "Right Way" to do it, and
that it would be whatever coreutil's rm did. If not then we are back to:
> delete-directory should simply catch ENOENT errors and ignore them
> when it deletes files and subdirectories under the "recursive" option.
> Other errors should signal an error as they do now.
This doesn't seem possible without changes at the C level.
Should there be a standard Lisp error for ENOENT?
Currently report_file_errno only does EEXIST -> file_already_exists.
Or should delete-file get a FORCE argument akin to "rm -f"?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Tue, 18 Oct 2016 16:57:02 GMT)
Full text and
rfc822 format available.
Message #24 received at 24714 <at> debbugs.gnu.org (full text, mbox):
I haven't tested it, but the files--force implementation looks a little
unaesthetic to me. Did you consider adding a standard condition error in
report_file_errno for ENOENT? There would then be symmetry with the
file-already-exists error for EEXIST.
Also, IMO this is purely a bug fix, and should not be mentioned in NEWS,
the lispref, or the doc.
But thanks for the fix!
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Tue, 18 Oct 2016 17:00:02 GMT)
Full text and
rfc822 format available.
Message #27 received at 24714 <at> debbugs.gnu.org (full text, mbox):
Glenn Morris wrote:
> I haven't tested it, but the files--force implementation looks a little
> unaesthetic to me.
PS will it work in non-English locales?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Wed, 19 Oct 2016 07:24:01 GMT)
Full text and
rfc822 format available.
Message #30 received at 24714 <at> debbugs.gnu.org (full text, mbox):
> From: Glenn Morris <rgm <at> gnu.org>
> Date: Tue, 18 Oct 2016 12:59:26 -0400
> Cc: 24714 <at> debbugs.gnu.org
>
> Glenn Morris wrote:
>
> > I haven't tested it, but the files--force implementation looks a little
> > unaesthetic to me.
>
> PS will it work in non-English locales?
Paul, what about this Glenn's question? The error strings are
localized, I think.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Thu, 20 Oct 2016 06:51:01 GMT)
Full text and
rfc822 format available.
Message #33 received at 24714 <at> debbugs.gnu.org (full text, mbox):
Eli Zaretskii wrote:
> Paul, what about this Glenn's question? The error strings are
> localized, I think.
Yes, his comments are spot on. I have written a fix but want to test it more
before installing.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Fri, 21 Oct 2016 11:54:01 GMT)
Full text and
rfc822 format available.
Message #36 received at 24714 <at> debbugs.gnu.org (full text, mbox):
On 10/19/2016 12:23 AM, Eli Zaretskii wrote:
>> From: Glenn Morris <rgm <at> gnu.org>
>> Date: Tue, 18 Oct 2016 12:59:26 -0400
>> Cc: 24714 <at> debbugs.gnu.org
>>
>> Glenn Morris wrote:
>>
>>> I haven't tested it, but the files--force implementation looks a little
>>> unaesthetic to me.
>>
>> PS will it work in non-English locales?
>
> Paul, what about this Glenn's question? The error strings are
> localized, I think.
What about attaching the numeric errno value to the error message as a
text property in report_file_errno?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Fri, 21 Oct 2016 12:10:01 GMT)
Full text and
rfc822 format available.
Message #39 received at 24714 <at> debbugs.gnu.org (full text, mbox):
On Okt 21 2016, Daniel Colascione <dancol <at> dancol.org> wrote:
> What about attaching the numeric errno value to the error message as a
> text property in report_file_errno?
errno values aren't portable either.
Andreas.
--
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Fri, 21 Oct 2016 12:11:01 GMT)
Full text and
rfc822 format available.
Message #42 received at 24714 <at> debbugs.gnu.org (full text, mbox):
On 10/21/2016 05:09 AM, Andreas Schwab wrote:
> On Okt 21 2016, Daniel Colascione <dancol <at> dancol.org> wrote:
>
>> What about attaching the numeric errno value to the error message as a
>> text property in report_file_errno?
>
> errno values aren't portable either.
True, but you can provide the value of EEXIST and others as constants
accessible to lisp.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Fri, 21 Oct 2016 12:56:01 GMT)
Full text and
rfc822 format available.
Message #45 received at 24714 <at> debbugs.gnu.org (full text, mbox):
> Cc: eggert <at> cs.ucla.edu, 24714 <at> debbugs.gnu.org
> From: Daniel Colascione <dancol <at> dancol.org>
> Date: Fri, 21 Oct 2016 04:53:40 -0700
>
> > Paul, what about this Glenn's question? The error strings are
> > localized, I think.
>
> What about attaching the numeric errno value to the error message as a
> text property in report_file_errno?
IMO, Glenn suggested a cleaner solution: to have a symbol for ENOENT.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#24714
; Package
emacs
.
(Fri, 21 Oct 2016 20:08:02 GMT)
Full text and
rfc822 format available.
Message #48 received at 24714 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 10/18/2016 09:55 AM, Glenn Morris wrote:
> Did you consider adding a standard condition error in
> report_file_errno for ENOENT? There would then be symmetry with the
> file-already-exists error for EEXIST.
Again, thanks for pointing that out. I installed the attached patch,
which does that. This also should fix the locale problem you mentioned
later.
[0001-New-error-file-missing.patch (application/x-patch, attachment)]
bug marked as fixed in version 26.1, send any further explanations to
24714 <at> debbugs.gnu.org and Glenn Morris <rgm <at> gnu.org>
Request was from
Glenn Morris <rgm <at> gnu.org>
to
control <at> debbugs.gnu.org
.
(Thu, 27 Oct 2016 02:46: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
.
(Thu, 24 Nov 2016 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 8 years and 261 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.