unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Vivien Mallet <Vivien.Mallet@inria.fr>
To: 9256@debbugs.gnu.org
Subject: bug#9256: Erroneous output from "verify-visited-file-modtime" (fileio.c)
Date: Sat, 06 Aug 2011 10:28:52 +0200	[thread overview]
Message-ID: <874o1vuenv.fsf@data.fbx.proxad.net> (raw)

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

Dear Emacs developers,

In Emacs 23 and Emacs 24 (built sometime ago from Git repository),
"(verify-visited-file-modtime (current-buffer))" sometimes returns 'nil'
instead of 't'. This happens often, even if the file has not been
modified by another program.

One reason is that stat can return an EINTR error. I am running
Linux. According to the manpages, stat is not supposed to fail with
EINTR under a Posix system (contrary to SVr4), but this is what I
observe. I checked with a call to printf right after the error, and I
got errno == 4 which is EINTR here. After exposing this on IRC #emacs, I
was told it could be due to the NFS mount (with option "intr") as the
files are on a network NFS volume. Hence I modified fileio.c to call
stat again after an EINTR error is raised. I attach the patch. If it is
confirmed that stat can return EINTR, there might be other calls to stat
in Emacs that need the correction.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fileio.patch --]
[-- Type: text/x-diff, Size: 808 bytes --]

diff --git a/src/fileio.c b/src/fileio.c
index 5d33fb9..611ccff 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4956,6 +4956,7 @@ See Info node `(elisp)Modification Time' for more details.  */)
   struct stat st;
   Lisp_Object handler;
   Lisp_Object filename;
+  int stat_status;
 
   if (NILP (buf))
     b = current_buffer;
@@ -4977,7 +4978,10 @@ See Info node `(elisp)Modification Time' for more details.  */)
 
   filename = ENCODE_FILE (BVAR (b, filename));
 
-  if (stat (SSDATA (filename), &st) < 0)
+  while ((stat_status = stat (SSDATA (filename), &st)) < 0 && errno == EINTR);
+
+  /* if (stat (SSDATA (filename), &st) < 0) */
+  if (stat_status < 0)
     {
       /* If the file doesn't exist now and didn't exist before,
 	 we say that it isn't modified, provided the error is a tame one.  */

[-- Attachment #3: Type: text/plain, Size: 1124 bytes --]


This solved only part of the problem. I still get a lot of false 'nil'
from "(verify-visited-file-modtime (current-buffer))" because stat
returns ENOENT. One may argue this comes from my network, but the
problem appears only inside Emacs. I wrote a small program to call stat
a (huge) number of times on a regular basis (on a file previously opened
by the program), but I did not get a single error. Maybe the way Emacs
opens the files has something to do with that? I would be grateful to
you if you could suggest a few tests to find out why Emacs may
experience problems with stat while other programs do not seem to face
the issue at all (no EINTR, no ENOENT).

Note that, on this network, the problem is met by all Emacs users I
know, whatever their Emacs configuration. The computers are running
Linux 2.6.32-31-generic x86_64, under Ubuntu 10.10. The involved Emacs
versions are 23.1.1 (Ubuntu package) and 24 (git commit
78cda4761357774eb9daa19546a078f24aa1ee66 from 19 March 2011). I was told
the problem does not appear in Emacs 22, but I did not check it myself.

Thank you for the great work.

Best regards,
VM.

             reply	other threads:[~2011-08-06  8:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-06  8:28 Vivien Mallet [this message]
2019-11-23 13:44 ` bug#9256: Erroneous output from "verify-visited-file-modtime" (fileio.c) Lars Ingebrigtsen
2020-01-20  9:36 ` Paul Eggert
2020-01-20 15:36   ` Andy Moreton
2020-01-20 17:20     ` Eli Zaretskii
2020-01-20 18:06       ` Andy Moreton

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=874o1vuenv.fsf@data.fbx.proxad.net \
    --to=vivien.mallet@inria.fr \
    --cc=9256@debbugs.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).