Subject: Re: bug#70973: 29.1; "Unlocking file: Invalid argument" Warning saving via a softlink with stale file lock

From: Eli Zaretskii <[email-masked]>
Date: Thu, 16 May 2024 11:43:45 +0300

> From: Duncan Greatwood <[email-masked]>
> Date: Wed, 15 May 2024 17:53:05 -0700
> 
> While editing the ~/.emacs file in emacs, the machine rebooted (kernel panic I believe). This left a lock file
> behind.
> 
> The ~/.emacs file is actually a softlink:
> .emacs -> /Users/<username>/Dropbox/Documents/Projects/emacs/dotemacs
> The fact that it's a softlink may or may not be relevant.
> 
> In ~/Dropbox/Documents/Projects/emacs/, there was a file: .#dotemacs
> 
> After the reboot, I started emacs, and continued with further edits to .emacs. Upon saving .emacs, had the
> following warning:
> ⛔ Warning (unlock-file): Unlocking file: Invalid argument, ~/Dropbox/Documents/Projects/emacs/dotemacs,
> ignored
> 
> As per the warning, the save was nonetheless successful.
> 
> Invoking file-locked-p directly, I saw the same error, and the following debug info:
> Debugger entered--Lisp error: (file-error "Testing file lock" "Invalid argument"
> "~/Dropbox/Documents/Projects/emacs/dotemacs")
>   file-locked-p("~/Dropbox/Documents/Projects/emacs/dotemacs")
>   eval((file-locked-p "~/Dropbox/Documents/Projects/emacs/dotemacs") t)
>   eval-expression((file-locked-p "~/Dropbox/Documents/Projects/emacs/dotemacs") nil nil 127)
>   funcall-interactively(eval-expression (file-locked-p "~/Dropbox/Documents/Projects/emacs/dotemacs") nil nil
> 127)
>   call-interactively(eval-expression nil nil)
>   command-execute(eval-expression)
> 
> After removing the lock file manually, the warning on save goes away:
> rm ~/Dropbox/Documents/Projects/emacs/.#dotemacs
> 
> Access flags on dotemacs file are as follows:
> -rw-r--r--@  1 dgreatwood  staff  133806 May 15 16:01 dotemacs
> lrwxr-xr-x  1 dgreatwood  staff  59 Dec  6  2015 .emacs -> ...

Thanks.

However, this doesn't provide enough information to investigate the
issue and its causes.  If you can reproduce the problem, please tell
what does

  ls -l ~/Dropbox/Documents/Projects/emacs/.#dotemacs

produce when you see the warnings, because that is the immediate
trigger for the "invalid argument".