bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#23397: 25.0.92; assertion failure auto-reverting a file being overwr


From: Noam Postavsky
Subject: bug#23397: 25.0.92; assertion failure auto-reverting a file being overwritten
Date: Sat, 16 Jun 2018 17:45:36 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

found 23397 26.1
tags 23397 + confirmed
quit

Ken Raeburn <address@hidden> 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);







reply via email to

[Prev in Thread] Current Thread [Next in Thread]