From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#8496: some file locking code in insert-file-contents cannot be right Date: Thu, 14 Apr 2011 02:48:28 -0400 Message-ID: References: <4DA64291.5060207@cs.ucla.edu> Reply-To: Eli Zaretskii NNTP-Posting-Host: lo.gmane.org X-Trace: dough.gmane.org 1302764857 12655 80.91.229.12 (14 Apr 2011 07:07:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 14 Apr 2011 07:07:37 +0000 (UTC) Cc: 8496@debbugs.gnu.org To: Paul Eggert Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Apr 14 09:07:33 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QAGeK-0001ww-Q8 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Apr 2011 09:07:32 +0200 Original-Received: from localhost ([::1]:42712 helo=lists2.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAGeK-0006Xn-65 for geb-bug-gnu-emacs@m.gmane.org; Thu, 14 Apr 2011 03:07:32 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:36255) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAGeG-0006XX-To for bug-gnu-emacs@gnu.org; Thu, 14 Apr 2011 03:07:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QAGeA-0007dr-UB for bug-gnu-emacs@gnu.org; Thu, 14 Apr 2011 03:07:28 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QAGeA-0007dn-RK for bug-gnu-emacs@gnu.org; Thu, 14 Apr 2011 03:07:22 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1QAGMQ-0007MU-25; Thu, 14 Apr 2011 02:49:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Apr 2011 06:49:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8496 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 8496-submit@debbugs.gnu.org id=B8496.130276371728267 (code B ref 8496); Thu, 14 Apr 2011 06:49:01 +0000 Original-Received: (at 8496) by debbugs.gnu.org; 14 Apr 2011 06:48:37 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QAGM0-0007Lr-Vu for submit@debbugs.gnu.org; Thu, 14 Apr 2011 02:48:37 -0400 Original-Received: from fencepost.gnu.org ([140.186.70.10]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QAGLx-0007Lf-Pg for 8496@debbugs.gnu.org; Thu, 14 Apr 2011 02:48:34 -0400 Original-Received: from eliz by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1QAGLs-0008AI-9M; Thu, 14 Apr 2011 02:48:28 -0400 In-reply-to: <4DA64291.5060207@cs.ucla.edu> (message from Paul Eggert on Wed, 13 Apr 2011 17:40:49 -0700) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 14 Apr 2011 02:49:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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:45808 Archived-At: > Date: Wed, 13 Apr 2011 17:40:49 -0700 > From: Paul Eggert > > As a result of the "mark unexported symbols 'static'" patch that I'm > working on, in the Emacs trunk I found some file-locking code inside > insert-file-contents that cannot be right: > > if (NILP (visit) && inserted > 0) > { > #ifdef CLASH_DETECTION > if (!NILP (BVAR (current_buffer, file_truename)) > /* Make binding buffer-file-name to nil effective. */ > && !NILP (BVAR (current_buffer, filename)) > && SAVE_MODIFF >= MODIFF) > we_locked_file = 1; > #endif /* CLASH_DETECTION */ > prepare_to_modify_buffer (GPT, GPT, NULL); > } > > The above code is equivalent to a no-op, since 'inserted' must > be zero here. In Emacs 21.4a, the corresponding code was this: if (!NILP (visit)) { ... #ifdef CLASH_DETECTION if (NILP (handler)) { if (!NILP (current_buffer->file_truename)) unlock_file (current_buffer->file_truename); unlock_file (filename); } #endif /* CLASH_DETECTION */ The change to the present form was between 21.4a and 22.1. It appears in the trunk history as part of a huge merge from a branch, probably the Emacs 22.1 release branch. I need more forensic work to find out why the change was made, but at this point it certainly looks like someone goofed with the condition. What platforms use CLASH_DETECTION?