GNU bug report logs - #43535
File locking on Windows

Previous Next

Package: emacs;

Reported by: Richard Copley <rcopley <at> gmail.com>

Date: Sun, 20 Sep 2020 15:56:02 UTC

Severity: normal

Tags: moreinfo

Done: Lars Ingebrigtsen <larsi <at> gnus.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 43535 in the body.
You can then email your comments to 43535 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-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sun, 20 Sep 2020 15:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Richard Copley <rcopley <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 20 Sep 2020 15:56:02 GMT) Full text and rfc822 format available.

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

From: Richard Copley <rcopley <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: File locking on Windows
Date: Sun, 20 Sep 2020 16:54:56 +0100
Recipe from "emacs -Q", on Windows:

Visit a file "x.cpp". Modify the buffer and don't save.

    M-! clang-format -i *.cpp RET

This has the effect of altering the contents of the lock file
".#x.cpp". Most Windows programs that accept wildcards and edit files
in place will do the same, since they don't usually skip dot files.
Now we are in a pickle:

    M-x revert-buffer RET
    yes RET

Error:  Unlocking file: Invalid argument, c:/x.cpp

    C-x k RET
    yes RET

Error: Unlocking file: Invalid argument, c:/x.cpp

    C-x C-c
    n
    yes RET

Emacs doesn't close or print an error but becomes unusable, having
apparently deleted all windows. You can still use the minibuffer.
Delete the lock file and kill Emacs:

    M-! del .#x RET
    C-x C-c
    n
    yes RET

This is quite a cruel punishment for an understandable mistake. I
assume it started happening when Paul fixed the error handling in
"filelock.c". It happens on master and Emacs 27.2, and not on Emacs
26.3.

There is more than one conceivable way to avoid this. E.g., use a
different lock file name, keep the lock file open in deny-share mode
to prevent accidents, ignore certain errors while unlocking. In fact
I'd like to have an option to permanently disable creating lock files.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sun, 20 Sep 2020 16:04:02 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: 43535 <at> debbugs.gnu.org
Subject: Re: bug#43535: File locking on Windows
Date: Sun, 20 Sep 2020 19:03:08 +0300
> From: Richard Copley <rcopley <at> gmail.com>
> Date: Sun, 20 Sep 2020 16:54:56 +0100
> 
> I'd like to have an option to permanently disable creating lock files.

I think you should be able to do that by customizing the variable
create-lockfiles.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sun, 20 Sep 2020 16:15:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: 43535 <at> debbugs.gnu.org
Subject: Re: bug#43535: File locking on Windows
Date: Sun, 20 Sep 2020 19:14:19 +0300
> From: Richard Copley <rcopley <at> gmail.com>
> Date: Sun, 20 Sep 2020 16:54:56 +0100
> 
> This is quite a cruel punishment for an understandable mistake. I
> assume it started happening when Paul fixed the error handling in
> "filelock.c". It happens on master and Emacs 27.2, and not on Emacs
> 26.3.
> 
> There is more than one conceivable way to avoid this. E.g., use a
> different lock file name, keep the lock file open in deny-share mode
> to prevent accidents, ignore certain errors while unlocking.

I think ignoring errors, perhaps after asking for confirmation, is the
only way.  Using a different file name will just move the problem
elsewhere, and keeping the file open will disallow stealing the lock,
and on MS-Windows will have other annoying effects (like keeping the
file's directory busy etc.).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sun, 20 Sep 2020 17:34:02 GMT) Full text and rfc822 format available.

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

From: Richard Copley <rcopley <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 43535 <at> debbugs.gnu.org
Subject: Re: bug#43535: File locking on Windows
Date: Sun, 20 Sep 2020 18:32:50 +0100
Eli Zaretskii wrote:
> > I'd like to have an option to permanently disable creating lock files.
> I think you should be able to do that by customizing the variable
> create-lockfiles.

Thanks.

> I think ignoring errors, perhaps after asking for confirmation, is the
> only way.  Using a different file name will just move the problem
> elsewhere, and keeping the file open will disallow stealing the lock,
> and on MS-Windows will have other annoying effects (like keeping the
> file's directory busy etc.).

Right.
Parse failure in "current_lock_owner" isn't handled well. You can
force the same issues to occur on a non-Windows system by deleting the
".#x" symlink and recreating it with a bad target.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sat, 31 Jul 2021 13:06:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 43535 <at> debbugs.gnu.org
Subject: Re: bug#43535: File locking on Windows
Date: Sat, 31 Jul 2021 15:05:15 +0200
Richard Copley <rcopley <at> gmail.com> writes:

> Parse failure in "current_lock_owner" isn't handled well. You can
> force the same issues to occur on a non-Windows system by deleting the
> ".#x" symlink and recreating it with a bad target.

I tried reproducing this in Debian:

cd tmp
touch foo
ln -s noexist .#foo

and then editing and saving /tmp/foo:

Warning (unlock-file): Unlocking file: Invalid argument, /tmp/foo, ignored

So a warning pops up here...  which I think is reasonable?

Do you see something different?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 31 Jul 2021 13:06:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sat, 31 Jul 2021 13:37:02 GMT) Full text and rfc822 format available.

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

From: Richard Copley <rcopley <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 43535 <at> debbugs.gnu.org
Subject: Re: bug#43535: File locking on Windows
Date: Sat, 31 Jul 2021 14:36:15 +0100
Lars wrote:

> Do you see something different?

No. Looks like this was fixed collateral to
<https://debbugs.gnu.org/cgi/bugreport.cgi?bug=46397>.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sat, 31 Jul 2021 14:16:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 43535 <at> debbugs.gnu.org
Subject: Re: bug#43535: File locking on Windows
Date: Sat, 31 Jul 2021 16:15:30 +0200
Richard Copley <rcopley <at> gmail.com> writes:

>> Do you see something different?
>
> No. Looks like this was fixed collateral to
> <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=46397>.

OK; good.  But does this mean that the reported bug on Windows is also
gone?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#43535; Package emacs. (Sun, 29 Aug 2021 20:18:03 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Richard Copley <rcopley <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 43535 <at> debbugs.gnu.org
Subject: Re: bug#43535: File locking on Windows
Date: Sun, 29 Aug 2021 22:17:41 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Richard Copley <rcopley <at> gmail.com> writes:
>
>>> Do you see something different?
>>
>> No. Looks like this was fixed collateral to
>> <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=46397>.
>
> OK; good.  But does this mean that the reported bug on Windows is also
> gone?

More information was requested, but no response was given within a
month, so I'm closing this bug report.  If the problem still exists,
please respond to this email and we'll reopen the bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug closed, send any further explanations to 43535 <at> debbugs.gnu.org and Richard Copley <rcopley <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 29 Aug 2021 20:19: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. (Mon, 27 Sep 2021 11:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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