GNU bug report logs - #8496
some file locking code in insert-file-contents cannot be right

Previous Next

Package: emacs;

Reported by: Paul Eggert <eggert <at> cs.ucla.edu>

Date: Thu, 14 Apr 2011 00:42:02 UTC

Severity: normal

Done: Andreas Schwab <schwab <at> linux-m68k.org>

Bug is archived. No further changes may be made.

Full log


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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Eggert <eggert <at> cs.ucla.edu>
Cc: 8496 <at> debbugs.gnu.org
Subject: Re: bug#8496: some file locking code in insert-file-contents cannot be
	right
Date: Thu, 14 Apr 2011 02:48:28 -0400
> Date: Wed, 13 Apr 2011 17:40:49 -0700
> From: Paul Eggert <eggert <at> cs.ucla.edu>
> 
> 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?




This bug report was last modified 14 years and 41 days ago.

Previous Next


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