[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that
From: |
Matt Armstrong |
Subject: |
bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file |
Date: |
Thu, 11 Feb 2021 14:14:52 -0800 |
Paul Eggert <eggert@cs.ucla.edu> writes:
> The second bug is that once you're in a tricky situation where the file
> can't be unlocked for whatever reason and you attempt to exit Emacs,
> Emacs tries to auto-save the buffer, fails because of the lock problem,
> and then gets into a weird state where you cannot do anything. This
> problem can happen in other scenarios. For example:
>
> * Run Emacs and visit the file /tmp/a/b where /tmp/a does not exist.
> Emacs will warn "Use M-x make-directory RET RET to create the directory
> and its parents"; ignore the warning.
>
> * Type some characters so that /tmp/a/b's buffer is nonempty.
>
> * Create an inaccessible directory /tmp/a by running "mkdir -m 0 /tmp/a"
> outside Emacs.
>
> * Type C-x C-c to exit Emacs. It will say "Save file /tmp/a/b?" Type
> "n". It will then say "Modified buffers exist; exit anyway? (yes or
> no)". Type "yes". Emacs will then hang, in a weird state where it is
> trying to auto-save but hanging in the middle of that.
>
> I did not fix this latter problem, so it needs further investigation.
Paul, I looked into this second issue a bit.
The issue isn't confined to exiting Emacs. It appears that once in a
"tricky situation where the file can't be unlocked for whatever reason"
Emacs will refuse to kill the buffer because unlock_file() signals an
error.
The problem is more severe when exiting Emacs because it occurs after
Emacs is in a half shut down state. The shutdown sequence does not take
kindly to the unhandled non-local exit.
I used this for a quick repro:
(cl-flet ((command-in-tmp (prog &rest args)
(with-temp-buffer
(cd-absolute "/tmp")
(apply #'call-process prog nil nil nil args))))
(command-in-tmp "chmod" "u+rwx" "a")
(command-in-tmp "rm" "-rf" "a")
(find-file "/tmp/a/b")
(insert "Hello, World!")
(command-in-tmp "mkdir" "-m" "0" "a"))
At shutdown, the following call stack signals an error:
kill_emacs
-> shut_down_emacs
-> unlock_all_files
-> unlock_file
-> report_file_errno
In this case, the errno is "permission denied."
Note that shut_down_emacs() calls Fdo_auto_save() just before
unlock_all_files() and that call succeeds. Fdo_auto_save() also calls
report_file_errno, throwing an errno 13 (Permission denied), but that
recovers and continues.
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, (continued)
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Matt Armstrong, 2021/02/09
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/10
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Paul Eggert, 2021/02/10
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/10
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Matt Armstrong, 2021/02/10
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/12
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Paul Eggert, 2021/02/12
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/12
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Matt Armstrong, 2021/02/12
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/13
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file,
Matt Armstrong <=
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Paul Eggert, 2021/02/11
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/12
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Matt Armstrong, 2021/02/12
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Paul Eggert, 2021/02/12
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/13
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/13
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Matt Armstrong, 2021/02/13
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/14
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Matt Armstrong, 2021/02/14
- bug#46397: 27.1; Cannot delete buffer pointing to a file in a path that includes a file, Eli Zaretskii, 2021/02/15