Subject: 31.0.50; "Unlocking file: Invalid argument" when deleting lock file on network file system

From: Michal Nazarewicz <[email-masked]>
Date: Thu, 15 Aug 2024 17:59:21 +0200

[Sending this again as a new bug report since #70973 is archived].

On Thu, May 16 2024, Eli Zaretskii wrote:
> 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.

I’m getting the same warning on Linux with Emacs 31.0.50 and it’s not
caused by a crash.

    emacs> M-x find-file RET /o/foo RET blah RET
    cli> $ ls -l /o/.#foo 
    cli> -rw------- 1 mpn mpn 0 2024-08-15 16:30 /o/.#foo
    emacs> M-x save-buffer RET
    emacs> ⛔ Warning (unlock-file): Unlocking file: Invalid argument, /o/foo, ignored
    cli> $ ls -l /o/.#foo /o/foo
    cli> -rw------- 1 mpn mpn 5 2024-08-15 16:31 /o/foo
    cli> -rw------- 1 mpn mpn 0 2024-08-15 16:30 /o/.#foo

The problem appears to be that /o is a network file-system which does
not support symbolic links:

    $ mount |grep /o
    //192.168.x.x/data on /o type cifs (rw,relatime,vers=3.0,cache=strict,username=mpn,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.x.x,file_mode=0600,dir_mode=0700,soft,nounix,serverino,mapposix,reparse=nfs,rsize=4194304,wsize=4194304,bsize=1048576,retrans=1,echo_interval=60,actimeo=1,closetimeo=1,_netdev)
    $ ln -s /o/foo /o/f
    ln: failed to create symbolic link '/o/f': Input/output error

I guess Emacs notices that when it tries to create a lock file and falls
back to creating a file, but then it assumes it’s a symlink when trying
to remove it.

---------- >8 ------------------------------------------------------
In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.43, cairo version 1.18.0) of 2024-08-12 built on erwin
Repository revision: 5d69e2916458148159d7f21257f3c4863b868690
Repository branch: HEAD
Windowing system distributor 'The X.Org Foundation', version 11.0.12101011
System Description: Debian GNU/Linux trixie/sid

Configured using:
 'configure --prefix=/usr/local --disable-acl
 --enable-link-time-optimization --with-native-compilation=aot
 --without-dbus --without-gconf --without-gpm --without-gsettings
 --without-pop --without-selinux --without-systemd
 --without-toolkit-scroll-bars --with-x --with-x-toolkit=gtk3
 --with-xinput2 --with-xml2 'CFLAGS=-O2 -mtune=native -march=native
 -fstack-protector' 'CPPFLAGS=-O2 -mtune=native -march=native
 -fstack-protector' 'CXXFLAGS=-O2 -mtune=native -march=native
 -fstack-protector''

Configured features:
CAIRO FREETYPE GIF GLIB GMP GNUTLS HARFBUZZ JPEG LIBXML2 MODULES
NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS TIFF WEBP
X11 XDBE XIM XINPUT2 XPM GTK3 ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LANG: en_GB.utf8
  locale-coding-system: utf-8-unix

Major mode: Rust

Minor modes in effect:
  server-mode: t
  flyspell-mode: t
  auto-dim-other-buffers-mode: t
  global-auto-revert-mode: t
  icomplete-mode: t
  global-num3-mode: t
  num3-mode: t
  global-whitespace-mode: t
  whitespace-mode: t
  global-flyspell-mode: t
  delete-selection-mode: t
  windmove-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  auto-fill-function: do-auto-fill
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
/home/mpn/.config/emacs/elpa/transient-20210525.1141/transient hides /usr/local/share/emacs/31.0.50/lisp/transient
~/.config/emacs/custom hides /usr/local/share/emacs/31.0.50/lisp/custom

Features:
(shadow emacsbug mm-archive parse-time iso8601 mule-util image-mode exif
wdired dired-aux pp network-stream nsm mailalias smtpmail textsec
uni-scripts idna-mapping ucs-normalize uni-confusable textsec-check qp
sort mail-extr notmuch notmuch-tree notmuch-jump notmuch-hello wid-edit
notmuch-show notmuch-print notmuch-crypto notmuch-mua notmuch-message
notmuch-draft notmuch-maildir-fcc notmuch-address notmuch-company
notmuch-parser format-spec notmuch-wash diff-mode track-changes coolj
goto-addr icalendar notmuch-tag crm notmuch-lib notmuch-compat pcase
hl-line mm-view mml-smime smime gnutls dig gnus-alias rot13 message
sendmail yank-media puny dired dired-loaddefs rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr
mailabbrev mail-utils gmm-utils mailheader calc-alg calc-ext calc-menu
calc calc-loaddefs calc-macs project dabbrev auto-package-update
easy-mmode dash rust-utils rust-mode rust-rustfmt rust-playpen
rust-compile rust-cargo time-date mc-hide-unmatched-lines-mode
mc-mark-more mc-cycle-cursors multiple-cursors-core rect misearch
multi-isearch conf-mode pulse color descr-text server flyspell form-feed
init sgml-mode facemenu dom auto-dim-other-buffers face-remap autorevert
filenotify comp comp-cstr cl-extra help-mode warnings comp-run
comp-common rx icomplete num3-mode disp-table whitespace compile
text-property-search comint ansi-osc ansi-color ring ispell remember
advice browse-kill-ring delsel ffap thingatpt windmove diary-lib
diary-loaddefs cal-menu calendar cal-loaddefs
auto-dim-other-buffers-autoloads avy-autoloads
browse-kill-ring-autoloads csv-mode-autoloads evil-autoloads
gnu-elpa-keyring-update-autoloads gnus-alias-autoloads finder-inf
markdown-mode-autoloads notmuch-autoloads protobuf-mode-autoloads
sed-mode-autoloads info vterm-autoloads package browse-url url url-proxy
url-privacy url-expand url-methods url-history url-cookie
generate-lisp-file url-domsuf url-util mailcap url-handlers url-parse
auth-source cl-seq eieio eieio-core cl-macs icons password-cache json
subr-x map byte-opt gv bytecomp byte-compile url-vars cl-loaddefs cl-lib
early-init rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads inotify dynamic-setting font-render-setting cairo gtk x-toolkit
xinput2 x multi-tty move-toolbar make-network-process native-compile
emacs)

Memory information:
((conses 16 667368 1514832) (symbols 48 33066 15)
 (strings 32 118043 64516) (string-bytes 1 3468194) (vectors 16 66157)
 (vector-slots 8 1624733 757680) (floats 8 247 2757)
 (intervals 56 57621 24687) (buffers 984 58))
---------- 8< ------------------------------------------------------

-- 
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»