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

From: Dmitry Gutov <[email-masked]>
Date: Mon, 14 Jan 2013 18:57:43 +0400

On 14.01.2013 9:10, Dmitry Gutov wrote:
> On 12.12.2012 2:54, Drew Adams wrote:
>>>> Anyway, hoping this helps in some way...
>>>
>>> I've been seeing the same kind of prompts lately when editing files in
>>> Emacs in Ubuntu inside a virtual machine.
>>>
>>> IIRC all those files were were mounted from the host machine
>>> (MS Windows 7) using the vboxsf file system type.
>>
>> Good to know that someone else is seeing something similar.
>>
>> In my case, I'm using Windows XP and am not using vboxsf or anything else
>> special - just an ordinary laptop.
>
> So, I can now reproduce it 100% in the conditions I mentioned above. And
> it's mighty annoying.
>
> 0. Open a file.
> 1. Make some changes. Emacs complies.
> 2. Press C-x C-s, saved successfully.
> 3. Try to make a single modification. Emacs instantly prompts "...
> changed on disk; really edit the buffer?".
>
> Answer yes -> goto 4, answer no -> goto 3.
> Answer "revert", buffer reverts, goto -> 1.
>
> 4. Make modifications, try to save: "... has changed since visited or
> save.  Save anyway?" Answer yes -> goto 2.
>
> If auto-revert-mode is enabled, and you wait the required interval of
> time after 2. without making modifications, the buffer is "reverted",
> also goto -> 1.
>
> All this on the latest trunk. A build from the latest emacs-24 doesn't
> exhibit the problem. Same with not-exactly-latest builds from these
> branches I had a few hours ago, with the possible exception of
> auto-revert-mode, IIRC it was less reliably helpful. Not sure.

Bisect points to revision 110875 
([email-masked]):
Fix a race with verify-visited-file-modtime.

Since at least 1991 Emacs has ignored an mtime difference of no
more than one second, but my guess is that this was to work around
file system bugs that were fixed long ago.  Since the race is
causing problems now, let's remove that code.
* fileio.c (Fverify_visited_file_modtime): Do not accept a file
whose time stamp is off by no more than a second.  Insist that the
file time stamps match exactly.

Paul, any suggestions?