GNU bug report logs - #13149
24.3.50; Emacs thinks file was changed outside Emacs, but it was not

Previous Next

Package: emacs;

Reported by: "Drew Adams" <drew.adams <at> oracle.com>

Date: Tue, 11 Dec 2012 21:53:02 UTC

Severity: normal

Tags: moreinfo, unreproducible

Found in version 24.3.50

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #118 received at 13149 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 13149 <at> debbugs.gnu.org, dgutov <at> yandex.ru
Subject: Re: bug#13149: 24.3.50; Emacs thinks file was changed outside Emacs,
	but it was not
Date: Fri, 18 Jan 2013 13:35:05 -0800
On 01/17/13 23:56, Eli Zaretskii wrote:
> Who said anything was actually written to the file?  You'd need
> 'fsync' to be sure, don't you?

That depends on what one means by "actually written".  :-)

POSIX says a 'write' must result in st_mtime being updated
some time before the file's time stamp is used (and 'fstat'
and 'stat' both count as uses).  It is not required that the
written data or the updated st_mtime physically be stored on
nonvolatile storage; if the system crashes, the updates might
get lost.]

Also, it's not required that st_mtime must be updated to the
exact time stamp of the write -- it can be updated to a later
time stamp, so long as the later time stamp comes before st_mtime's
first use.  But the point is that st_mtime must be updated
"in memory", so to speak, just as the file's data must get
updated "in memory", so that any uses of the file see the
new st_mtime and the new data that got written.

Here, we seem to have some cases where a write can occur
but st_mtime is not updated before the next stat or fstat.
I don't yet know how to characterize these cases, or how to
work around them.  Even Emacs's old approach (allow up to
1 second of slop) seems like it won't work in some cases
that have been reported here: over 2 seconds of slop in
<http://bugs.gnu.org/13149#115>, and over one minute of
slop in <http://bugs.gnu.org/13149##100>!

One approach that I've been toying with is that
Emacs could inspect the file system type, and if the file
system is known to be reliable (ext2, ufs, zfs, ...) we stick
with the new behavior in the trunk which uses fstat with no slop,
but otherwise we fall back on the Emacs-24 behavior, using stat
with 1 second of slop.  This won't allow the instances of
longer-than-1-second slops that we've seen reported here,
but maybe that's good enough.

I'm not particularly happy with this idea, but there is
a limit to what Emacs can do to work around filesystem bugs.




This bug report was last modified 11 years and 102 days ago.

Previous Next


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