GNU bug report logs - #9256
Erroneous output from "verify-visited-file-modtime" (fileio.c)

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Vivien Mallet <Vivien.Mallet@HIDDEN>; dated Sat, 6 Aug 2011 16:57:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 6 Aug 2011 16:56:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Aug 06 12:56:43 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QpkB0-0005bq-DB
	for submit <at> debbugs.gnu.org; Sat, 06 Aug 2011 12:56:42 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <Vivien.Mallet@HIDDEN>) id 1QpcGi-0007Hj-Cs
	for submit <at> debbugs.gnu.org; Sat, 06 Aug 2011 04:30:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Vivien.Mallet@HIDDEN>) id 1QpcFs-00041J-7v
	for submit <at> debbugs.gnu.org; Sat, 06 Aug 2011 04:29:14 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE
	autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:35407)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Vivien.Mallet@HIDDEN>) id 1QpcFs-000415-2K
	for submit <at> debbugs.gnu.org; Sat, 06 Aug 2011 04:29:12 -0400
Received: from eggs.gnu.org ([140.186.70.92]:35934)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Vivien.Mallet@HIDDEN>) id 1QpcFo-00014u-3q
	for bug-gnu-emacs@HIDDEN; Sat, 06 Aug 2011 04:29:11 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <Vivien.Mallet@HIDDEN>) id 1QpcFj-0003wC-KG
	for bug-gnu-emacs@HIDDEN; Sat, 06 Aug 2011 04:29:07 -0400
Received: from smtp3-g21.free.fr ([212.27.42.3]:47724)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <Vivien.Mallet@HIDDEN>) id 1QpcFi-0003sE-RI
	for bug-gnu-emacs@HIDDEN; Sat, 06 Aug 2011 04:29:03 -0400
Received: from data.fbx.proxad.net (unknown [88.166.87.133])
	by smtp3-g21.free.fr (Postfix) with ESMTP id E9B8CA6203
	for <bug-gnu-emacs@HIDDEN>; Sat,  6 Aug 2011 10:28:53 +0200 (CEST)
From: Vivien Mallet <Vivien.Mallet@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Erroneous output from "verify-visited-file-modtime" (fileio.c)
Organization: INRIA Paris-Rocquencourt
Date: Sat, 06 Aug 2011 10:28:52 +0200
Message-ID: <874o1vuenv.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -6.6 (------)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 06 Aug 2011 12:56:35 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.6 (------)

--=-=-=
Content-Type: text/plain

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.


--=-=-=
Content-Type: text/x-diff
Content-Disposition: attachment; filename=fileio.patch

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.  */

--=-=-=
Content-Type: text/plain


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.

--=-=-=--




Acknowledgement sent to Vivien Mallet <Vivien.Mallet@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#9256; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.