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: Ken Raeburn
Subject: bug#23397: 25.0.92; assertion failure auto-reverting a file being overwritten
Date: Mon, 02 May 2016 16:43:12 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

> So you are saying that the file's contents was updated between the
> time we called 'fstat' at the beginning of the function and the time
> we used st.st_size in the above snippet?

That's my guess. Or, more specifically, between the fstat and attempting
to go ahead and read data anyway.

But I did a few experiments with truncating the file and using a
breakpoint after the fstat to stall Emacs while I restored the file (so
the size appeared to be zero but all the data was readable), and nothing
interesting happened. That part of the function seems to be trying to
figure out if some of the beginning and end of the file are unchanged
from before, so I think maybe it also requires having some part in the
middle changed, or one version of the file being shorter than the other.
I'll run a few more experiments today to see.

> If so, perhaps we should call 'fstat' again each time we want to use
> st.st_size, and retry from the beginning if we find a mismatch?

If the file is large, and being frequently updated in small increments,
that could delay us considerably, as we restart the process multiple
times. (Some of the files I use auto-revert mode on are log files in the
tens of megabytes. Last I tried, auto-revert-tail-mode didn't cope
nicely with the case where the file got truncated and rewritten, so
reverting the whole file seems to be the way to go for now.) And if we
put a limit on the number of iterations, the last time around we'll
still need to get it right.

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.





reply via email to

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