unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Duncan Greatwood <dgreatwood@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 70973@debbugs.gnu.org
Subject: bug#70973: 29.1; "Unlocking file: Invalid argument" Warning saving via a softlink with stale file lock
Date: Thu, 16 May 2024 14:36:37 -0700	[thread overview]
Message-ID: <CAGg=3NVstcd_hE3N5VNjj30uFN8hBEqDXPaTK-_v737hQ5L03g@mail.gmail.com> (raw)
In-Reply-To: <86msoph6wt.fsf@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 3689 bytes --]

I would agree that the issue was likely due to a system crash at an
inopportune moment.

Of course, if emacs did detect a bad lock file, it could prompt the user
for confirmation before removing / replacing it. No need to be silent.

The status quo, requiring a user to find and remove the lock file manually,
seems burdensome to my eye, albeit the issue is presumably rare. But
certainly it is a matter of taste.



On Thu, May 16, 2024 at 12:52 PM Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Duncan Greatwood <dgreatwood@gmail.com>
> > Date: Thu, 16 May 2024 12:27:05 -0700
> > Cc: 70973@debbugs.gnu.org
> >
> > I just tried editing a different file, client.cc, causing a lockfile to
> be created. Sure enough, just as you say, that
> > lockfile is a dangling symlink:
> > ls -al .#client.cc
> > lrwxr-xr-x@ 1 username  staff  40 May 16 11:39 .#client.cc ->
> username@DMG-MB-Air-15-2024.local.3071
> >
> > Then, returning to editing ~/.emacs (which, being a symlink, is actually
> editing ~
> > /Dropbox/Documents/Projects/emacs/dotemacs).
> > Again, this creates a dangling symlink as you would expect:
> > ls -l .#dotemacs
> > lrwxr-xr-x@ 1 username  staff  40 May 16 11:43 .#dotemacs ->
> username@DMG-MB-Air-15-2024.local.3071
> >
> > At this point, I tried doing a hard reboot (power cycle) to simulate the
> kernel crash I mentioned before. But
> > (not surprisingly) after the reboot the lock file still looks as you
> would expect.
> > ls -l .#dotemacs
> > lrwxr-xr-x@ 1 username  staff  40 May 16 11:43 .#dotemacs ->
> username@DMG-MB-Air-15-2024.local.3071
> >
> > Noting that, in the bad case, the lock file was not only not a dangling
> symlink as it should be, but was also of
> > zero size, I would speculate that the kernel crash happened right as
> emacs was part way through writing the
> > lockfile to disk.
> >
> > Taking a quick look at the emacs source, the C function create_lock_file
> calls emacs_symlink which in turn
> > calls the OS function symlink.
> >
> > The OS function symlink is commonly assumed to be atomic I believe (e.g.
> see
> > https://rcrowley.org/2010/01/06/things-unix-can-do-atomically.html).
> However in this case I would suspect that
> > the kernel crash terminated the symlink write before it could fully
> complete.
> >
> > To fix, perhaps emacs needs to check purported lock files and handle the
> case where they are not symlinks
> > and/or are of zero size, avoiding the need to remove the
> partially-written lock file manually.
>
> I'm not sure we should silently sweep these rare and special cases
> under the carpet.  The warning is just a warning, and manually
> deleting the lock file fixes even that.
>
> So I'm not sure we should do anything here, as long as the conclusion
> is that this happened due to a system crash in an opportune moment.
>

-- 
NOTICE: This email and its attachments may contain privileged and 
confidential information, only for the viewing and use of the intended 
recipient. If you are not the intended recipient, you are hereby notified 
that any disclosure, copying, distribution, acting upon, or use of the 
information contained in this email and its attachments is strictly 
prohibited and that this email and its attachments must be immediately 
returned to the sender and deleted from your system. If you received this 
email erroneously, please notify the sender immediately.  Xage Security, 
Inc. and its affiliates will never request personal information (e.g., 
passwords, Social Security numbers) via email.  Report suspicious emails to 
security-alerts@xage.com <mailto:security-alerts@xage.com>

[-- Attachment #2: Type: text/html, Size: 4991 bytes --]

  reply	other threads:[~2024-05-16 21:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16  0:53 bug#70973: 29.1; "Unlocking file: Invalid argument" Warning saving via a softlink with stale file lock Duncan Greatwood
2024-05-16  8:43 ` Eli Zaretskii
2024-05-16 14:17   ` Duncan Greatwood
2024-05-16 15:46     ` Eli Zaretskii
2024-05-16 15:55       ` Duncan Greatwood
2024-05-16 16:09         ` Eli Zaretskii
2024-05-16 16:20           ` Duncan Greatwood
2024-05-16 18:18             ` Eli Zaretskii
2024-05-16 19:27               ` Duncan Greatwood
2024-05-16 19:51                 ` Eli Zaretskii
2024-05-16 21:36                   ` Duncan Greatwood [this message]
2024-06-01 14:04                     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGg=3NVstcd_hE3N5VNjj30uFN8hBEqDXPaTK-_v737hQ5L03g@mail.gmail.com' \
    --to=dgreatwood@gmail.com \
    --cc=70973@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).