On 2/10/21 7:05 AM, Eli Zaretskii wrote: > I think instead of ignoring some errors, we should allow the user to > get out of these situations, after showing the error. That is, > instead of silently ignoring the error on some low level, we should > propagate it to userlock.el and allow the user to decide whether > he/she wants to ignore the error or do something about that. These > errors could mean something innocent, or they could mean something > more serious, and we shouldn't second-guess which one is it. I agree with this. However, I think there are two bugs here. The first bug is that the low-level locking code is busted, in that it thinks there's a lock file when ENOTDIR says there isn't. I installed the first attached patch into master to fix this bug. This patch isn't what Matt suggested - it's a bit earlier in the low-level C code where the bug really occurred. (The area that Matt was looking at was later on, when we have the lock and are removing it, and the ENOENT check there is for the rare case where NFS is being used and its unlink implementation gets confused and fails with ENOENT even though it was actually successful and where any error other than ENOENT is serious.) 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. While looking into it, though, I did see some longstanding code in files.el that could use a bit of sprucing up given the more-modern primitives available now, and so installed the second attached patch into master.