Subject: bug#13149: 24.3.50; Emacs thinks file was changed outside Emacs, but it was not

From: Paul Eggert <[email-masked]>
Date: Tue, 15 Jan 2013 13:47:17 -0800

On 01/15/13 13:38, Dmitry Gutov wrote:
> If this is too bizarre, please wait until I re-confirm this on a new virtual machine with a different distro.

It's strange all right: it indicates that time stamps
are spontaneously jumping by 2 or more seconds, which I
can't explain by any file system bugs that I can think of.
Maybe it's a new class of bugs, but we'd need to know more
about them.

Could you please try instrumenting via this patch instead?
It should help diagnosis.  Thanks.

=== modified file 'lib/stat-time.h'
--- lib/stat-time.h	2013-01-01 09:11:05 +0000
+++ lib/stat-time.h	2013-01-15 21:44:42 +0000
@@ -22,6 +22,7 @@
 
 #include <sys/stat.h>
 #include <time.h>
+#include <stdio.h>
 
 _GL_INLINE_HEADER_BEGIN
 #ifndef _GL_STAT_TIME_INLINE
@@ -134,18 +135,22 @@
 
 /* Return *ST's data modification time.  */
 _GL_STAT_TIME_INLINE struct timespec
-get_stat_mtime (struct stat const *st)
+get_stat_mtime (struct stat const *st, char const *file, int line)
 {
+  struct timespec t;
 #ifdef STAT_TIMESPEC
-  return STAT_TIMESPEC (st, st_mtim);
+  t = STAT_TIMESPEC (st, st_mtim);
 #else
-  struct timespec t;
   t.tv_sec = st->st_mtime;
   t.tv_nsec = get_stat_mtime_ns (st);
+#endif
+  fprintf (stderr, "%s:%d: stat_mtime=%ld.%09ld\n", file, line,
+	   (long) t.tv_sec, (long) t.tv_nsec);
   return t;
-#endif
 }
 
+#define get_stat_mtime(st) get_stat_mtime (st, __FILE__, __LINE__)
+
 /* Return *ST's birth time, if available; otherwise return a value
    with tv_sec and tv_nsec both equal to -1.  */
 _GL_STAT_TIME_INLINE struct timespec