GNU bug report logs - #23397
25.0.92; assertion failure auto-reverting a file being overwritten

Previous Next

Package: emacs;

Reported by: Ken Raeburn <raeburn <at> permabit.com>

Date: Thu, 28 Apr 2016 22:07:01 UTC

Severity: normal

Tags: confirmed

Found in versions 26.1, 25.0.92

Full log


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

From: Noam Postavsky <npostavs <at> gmail.com>
To: Ken Raeburn <raeburn <at> permabit.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 23397 <at> debbugs.gnu.org
Subject: Re: bug#23397: 25.0.92;
 assertion failure auto-reverting a file being overwritten
Date: Sat, 16 Jun 2018 17:45:36 -0400
found 23397 26.1
tags 23397 + confirmed
quit

Ken Raeburn <raeburn <at> permabit.com> writes:

> There's code there doing lseek and read calls; we should be able to keep
> track of the last file position we read from, if that's not already
> derivable from existing variables visible at that point.

This seems to fix the scenario you gave in #17.  I don't quite
understand what the overlap expression is trying to compute though.

--- i/src/fileio.c
+++ w/src/fileio.c
@@ -3849,6 +3849,8 @@ because (1) it preserves some marker positions and (2) it puts less data
 	  goto handled;
 	}
 
+      off_t file_end_pos = st.st_size;
+
       /* Count how many chars at the end of the file
 	 match the text at the end of the buffer.  But, if we have
 	 already found that decoding is necessary, don't waste time.  */
@@ -3879,6 +3881,8 @@ because (1) it preserves some marker positions and (2) it puts less data
 	      total_read += nread;
 	    }
 
+          file_end_pos = max (curpos - trial + total_read, file_end_pos);
+
 	  /* Scan this bufferful from the end, comparing with
 	     the Emacs buffer.  */
 	  bufpos = total_read;
@@ -3931,7 +3935,7 @@ because (1) it preserves some marker positions and (2) it puts less data
 	  /* Don't try to reuse the same piece of text twice.  */
 	  overlap = (same_at_start - BEGV_BYTE
 		     - (same_at_end
-			+ (! NILP (end) ? end_offset : st.st_size) - ZV_BYTE));
+			+ (! NILP (end) ? end_offset : file_end_pos) - ZV_BYTE));
 	  if (overlap > 0)
 	    same_at_end += overlap;
 	  same_at_end_charpos = BYTE_TO_CHAR (same_at_end);






This bug report was last modified 4 years and 340 days ago.

Previous Next


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