From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#13149: 24.3.50; Emacs thinks file was changed outside Emacs, but it was not Date: Sat, 02 Feb 2013 11:31:34 -0800 Organization: UCLA Computer Science Department Message-ID: <510D6996.4050705@cs.ucla.edu> References: <6CDE13E3BCAA4AFAAB8BCE105C6ABF12@us.oracle.com> <50F484CB.6010905@gmail.com> <50F4FB0B.5070003@cs.ucla.edu> <50F5192B.602@yandex.ru> <50F5928A.9010009@cs.ucla.edu> <50F5CC3D.5090802@yandex.ru> <50F5CE65.9030002@cs.ucla.edu> <50F5D3F5.6050604@yandex.ru> <50F5DA58.3020404@cs.ucla.edu> <50F5E1C1.2040301@yandex.ru> <50F5E9DB.1030309@gmail.com> <50F64149.6010704@cs.ucla.edu> <50F7D358.9030100@gmail.com> <50F86E12.3040707@cs.ucla.edu> <50F8D150.8030200@gmail.com> <50F8D731.5020001@cs.ucla.edu> <50F8D93B.1040901@yandex.ru> <50F8DCCB.1030602@cs.ucla.edu> <83a9s67wlr.fsf@gnu.org> <50F9C009.9060708@cs.ucla.edu> <50F9D213.3070901@yandex.ru> <50F9EF01.5000703@cs.ucla.edu> <50F9F250.1030406@yandex.ru> <50FA06F1.2000308@cs.ucla.edu> <50FA1AEF.9070700@yandex.ru> <50FA265E.80301@cs.ucla.edu> <510C2E22.9010807@cs.ucla.edu> <83k3qrawcu.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1359833536 29594 80.91.229.3 (2 Feb 2013 19:32:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 2 Feb 2013 19:32:16 +0000 (UTC) Cc: 13149@debbugs.gnu.org, dgutov@yandex.ru To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 02 20:32:35 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1U1ipC-0006ot-To for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Feb 2013 20:32:31 +0100 Original-Received: from localhost ([::1]:56471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1iou-0000AV-Ih for geb-bug-gnu-emacs@m.gmane.org; Sat, 02 Feb 2013 14:32:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1ior-0000AQ-5S for bug-gnu-emacs@gnu.org; Sat, 02 Feb 2013 14:32:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U1iop-0006Po-W6 for bug-gnu-emacs@gnu.org; Sat, 02 Feb 2013 14:32:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55972) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U1iop-0006Pe-TO for bug-gnu-emacs@gnu.org; Sat, 02 Feb 2013 14:32:07 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1U1ipi-0002wF-Dc for bug-gnu-emacs@gnu.org; Sat, 02 Feb 2013 14:33:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 02 Feb 2013 19:33:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13149 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: unreproducible moreinfo Original-Received: via spool by 13149-submit@debbugs.gnu.org id=B13149.135983355611240 (code B ref 13149); Sat, 02 Feb 2013 19:33:02 +0000 Original-Received: (at 13149) by debbugs.gnu.org; 2 Feb 2013 19:32:36 +0000 Original-Received: from localhost ([127.0.0.1]:33203 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U1ipH-0002vE-TH for submit@debbugs.gnu.org; Sat, 02 Feb 2013 14:32:36 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:51508) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1U1ipE-0002v0-3s for 13149@debbugs.gnu.org; Sat, 02 Feb 2013 14:32:34 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 36AAD39E8100; Sat, 2 Feb 2013 11:31:36 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id q+raz03bNunY; Sat, 2 Feb 2013 11:31:35 -0800 (PST) Original-Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 6A46B39E8008; Sat, 2 Feb 2013 11:31:35 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 In-Reply-To: <83k3qrawcu.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70617 Archived-At: On 02/02/2013 01:38 AM, Eli Zaretskii wrote: > My testing indicates that a file on NTFS has its time stamp changed in > this scenario, while a file on FAT32 will not. OK, thanks, then we need to check for that problem too. Rather than go through a lengthy remote debugging session with Drew, I'm inclined to disable the heuristic on MS-Windows, as that should fix the problem once and for all. That is, we just live with the race conditions on MS-Windows (which is what Emacs users have done for many years) and fix the race conditions only on GNU and other systems that support POSIX.1-2008 well. I installed the following patch to try to do that, as trunk bzr 111664. If Drew continues to have the problem even with this patch, we can investigate further by inserting some logging code along the lines that we discussed. === modified file 'src/ChangeLog' --- src/ChangeLog 2013-02-02 17:14:24 +0000 +++ src/ChangeLog 2013-02-02 19:18:00 +0000 @@ -1,3 +1,14 @@ +2013-02-02 Paul Eggert + + Avoid file time stamp bug on MS-Windows (Bug#13149). + * fileio.c (Fwrite_region): Don't use the heuristic on empty files, + as FAT32 doesn't update time stamps when truncating them. + Also, check that a file time stamp is not a multiple of 100 ns; + this should catch all instances of the problem on MS-Windows, + as its native file system resolution is 100 ns or worse, and + checking for a non-multiple of 100 ns should impose only a small + overhead on systems with ns resolution. + 2013-02-02 Eli Zaretskii Avoid encoding file names on MS-Windows when they need to be run === modified file 'src/fileio.c' --- src/fileio.c 2013-02-02 17:14:24 +0000 +++ src/fileio.c 2013-02-02 19:18:00 +0000 @@ -5020,11 +5020,22 @@ if (fstat (desc1, &st1) == 0 && st.st_dev == st1.st_dev && st.st_ino == st1.st_ino) { + /* Use the heuristic if it appears to be valid. With neither + O_EXCL nor O_TRUNC, if Emacs happened to write nothing to the + file, the time stamp won't change. Also, some non-POSIX + systems don't update an empty file's time stamp when + truncating it. Finally, file systems with 100 ns or worse + resolution sometimes seem to have bugs: on a system with ns + resolution, checking ns % 100 incorrectly avoids the heuristic + 1% of the time, but the problem should be temporary as we will + try again on the next time stamp. */ + bool use_heuristic + = ((open_flags & (O_EXCL | O_TRUNC)) != 0 + && st.st_size != 0 + && EMACS_NSECS (modtime) % 100 != 0); + EMACS_TIME modtime1 = get_stat_mtime (&st1); - /* If neither O_EXCL nor O_TRUNC is used, and Emacs happened to - write nothing to the file, the file's time stamp won't change - so it should not be used in this heuristic. */ - if ((open_flags & (O_EXCL | O_TRUNC)) != 0 + if (use_heuristic && EMACS_TIME_EQ (modtime, modtime1) && st.st_size == st1.st_size) {