unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Michal Nazarewicz <mina86@mina86.com>
To: Paul Eggert <eggert@cs.ucla.edu>, Eli Zaretskii <eliz@gnu.org>
Cc: 72641@debbugs.gnu.org
Subject: bug#72641: 31.0.50; "Unlocking file: Invalid argument" when deleting lock file on network file system
Date: Sat, 17 Aug 2024 22:03:24 +0200	[thread overview]
Message-ID: <bmv2qte2mlyzfm00gya3p03k@mina86.com> (raw)
In-Reply-To: <e3baead8-0cfb-46aa-aa4c-6f3939f39887@cs.ucla.edu>

This appears to be network synchronisation issue.  I’ve run this
program:

---------- >8 --------------------------------------------------
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

void create(char *path) {
	int ret = symlink("dummy", path);
	if (ret < 0) {
		printf("%s: %d %s\n", path, errno, strerror(errno));
	} else {
		printf("%s: Ok\n", path);
	}
}

int check(char *path) {
	char buf[1024];
	ssize_t ret = readlink(path, buf, 1024);
	if (ret >= 0) {
		printf("%s: %.*s\n", path, ret, buf);
		return 0;
	}
	int err = errno;
	printf("%s: %d %s\n", path, err, strerror(err));
	return err;
}

int main(int argc, char **argv) {
	char *path = argc < 2 ? "bar" : argv[1];
	create(path);
	int loop = 0;
	while (check(path) != EINVAL && ++loop < 50) {
		usleep(100000);
	}
	return 0;
}
-------------------------------------------------- 8< ----------

and got the following:

---------- >8 --------------------------------------------------
/o/foo: 5 Input/output error
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 2 No such file or directory
/o/foo: 22 Invalid argument
-------------------------------------------------- 8< ----------

It looks like symlink(2) fails with EIO while the server creates
a regular file, however it takes the client to notice another second.


If you’re still interested, here’s strace when I find-file and then
kill-current-buffer without saving:

---------- >8 --------------------------------------------------
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                      = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY) = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o", 0x7ffec38f7370, 1024)                      = -1 EINVAL (Invalid argument)
readlinkat(AT_FDCWD, "/o/foo", 0x7ffec38f74d0, 1024)                  = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH)  = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o", 0x7ffec38f72c0, 1024)                      = -1 EINVAL (Invalid argument)
readlinkat(AT_FDCWD, "/o/foo", 0x7ffec38f7420, 1024)                  = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH)  = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC)                    = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o/.#foo", 0x7ffec38f13e8, 8193)                = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                      = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", W_OK, AT_EACCESS)                      = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                      = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o/foo", 0x7ffec38f7470, 1024)                  = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffec38f7750, 0)                     = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffec38f77f0, 0)                     = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo,v", F_OK, AT_EACCESS)                    = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY) = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY) = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY) = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY) = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffec38f5860, 0)                     = -1 ENOENT (No such file or directory)
symlink   ("mpn@erwin.223853:1723847375", "/o/.#foo")                 = -1 EIO (Input/output error)
readlinkat(AT_FDCWD, "/o/.#foo", 0x7ffec38f5ad8, 8193)                = -1 EINVAL (Invalid argument)
openat    (AT_FDCWD, "/o/.#foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC)       = 12
read      (12, "", 8193)                                              = 0
close     (12)                                                        = 0
unlink    ("/o/.#foo")                                                = 0
-------------------------------------------------- 8< ----------

And this is strace when I find-file and then save-buffer:

---------- >8 --------------------------------------------------
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                           = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o", 0x7ffe65452010, 1024)                           = -1 EINVAL (Invalid argument)
readlinkat(AT_FDCWD, "/o/foo", 0x7ffe65452170, 1024)                       = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH)       = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o", 0x7ffe65451f60, 1024)                           = -1 EINVAL (Invalid argument)
readlinkat(AT_FDCWD, "/o/foo", 0x7ffe654520c0, 1024)                       = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH)       = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC)                         = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o/.#foo", 0x7ffe6544c088, 8193)                     = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                           = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", W_OK, AT_EACCESS)                           = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                           = -1 ENOENT (No such file or directory)
readlinkat(AT_FDCWD, "/o/foo", 0x7ffe65452110, 1024)                       = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffe654523f0, 0)                          = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffe65452490, 0)                          = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo,v", F_OK, AT_EACCESS)                         = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffe65450500, 0)                          = -1 ENOENT (No such file or directory)
symlink   ("mpn@erwin.223938:1723847375", "/o/.#foo")                      = -1 EIO (Input/output error)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffe65452690, 0)                          = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                           = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo,v", F_OK, AT_EACCESS)                         = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY)      = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", F_OK, AT_EACCESS)                           = -1 ENOENT (No such file or directory)
faccessat2(AT_FDCWD, "/o/foo", W_OK, AT_EACCESS)                           = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH)       = -1 ENOENT (No such file or directory)
newfstatat(AT_FDCWD, "/o/foo", 0x7ffe6544ff80, 0)                          = -1 ENOENT (No such file or directory)
symlink   ("mpn@erwin.223938:1723847375", "/o/.#foo")                      = -1 EEXIST (File exists)
readlinkat(AT_FDCWD, "/o/.#foo", 0x7ffe65450078, 8193)                     = -1 EINVAL (Invalid argument)
openat    (AT_FDCWD, "/o/.#foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC)            = 12
read      (12, "", 8193)                                                   = 0
close     (12)                                                             = 0
unlink    ("/o/.#foo")                                                     = 0
symlink   ("mpn@erwin.223938:1723847375", "/o/.#foo")                      = -1 EIO (Input/output error)
openat    (AT_FDCWD, "/o/foo", O_WRONLY|O_CREAT|O_TRUNC|O_CLOEXEC, 0666)   = 12
write     (12, "ao sneuhta soneht sanoteu snothe"..., 33)                  = 33
close     (12)                                                             = 0
newfstatat(AT_FDCWD, "/o/foo", {st_mode=S_IFREG|0600, st_size=33, ...}, 0) = 0
readlinkat(AT_FDCWD, "/o/.#foo", 0x7ffe65450028, 8193)                     = -1 ENOENT (No such file or directory)
openat    (AT_FDCWD, "/o/foo", O_RDONLY|O_NOFOLLOW|O_CLOEXEC|O_PATH)       = 12
close     (12)                                                             = 0
-------------------------------------------------- 8< ----------

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





  reply	other threads:[~2024-08-17 20:03 UTC|newest]

Thread overview: 23+ 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
2024-06-01 14:04                     ` Eli Zaretskii
2024-08-15 15:59                   ` bug#72641: 31.0.50; "Unlocking file: Invalid argument" when deleting lock file on network file system Michal Nazarewicz
     [not found]                   ` <2+lcnmedng9le3pwfn0gc79m@mina86.com>
     [not found]                     ` <86a5hd7o4t.fsf@gnu.org>
2024-08-15 17:44                       ` Michal Nazarewicz
2024-08-15 21:43                         ` Paul Eggert
2024-08-16  0:59                           ` Michal Nazarewicz
2024-08-16  3:20                             ` Paul Eggert
2024-08-17 20:03                               ` Michal Nazarewicz [this message]
2024-08-17 22:38                                 ` Paul Eggert
2024-08-17 22:55                                   ` Mike Kupfer
2024-08-17 23:08                                     ` Mike Kupfer
2024-08-18 21:15                                   ` Michal Nazarewicz
2024-08-18 21:25                                     ` Paul Eggert

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=bmv2qte2mlyzfm00gya3p03k@mina86.com \
    --to=mina86@mina86.com \
    --cc=72641@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --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).