all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ken Raeburn <raeburn@permabit.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 23397@debbugs.gnu.org
Subject: bug#23397: 25.0.92; assertion failure auto-reverting a file being overwritten
Date: Mon, 02 May 2016 16:43:12 -0400	[thread overview]
Message-ID: <6efuu0chsv.fsf@just-testing.permabit.com> (raw)
In-Reply-To: <83vb2wl83m.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 02 May 2016 19:47:57 +0300")

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	other threads:[~2016-05-02 20:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-28 22:05 bug#23397: 25.0.92; assertion failure auto-reverting a file being overwritten Ken Raeburn
2016-05-02 16:47 ` Eli Zaretskii
2016-05-02 20:43   ` Ken Raeburn [this message]
2016-05-03 15:15     ` Eli Zaretskii
2016-05-03 21:04       ` Ken Raeburn
2018-06-16 21:45     ` Noam Postavsky
2018-06-17  5:36       ` Eli Zaretskii
2020-09-05 14:03       ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6efuu0chsv.fsf@just-testing.permabit.com \
    --to=raeburn@permabit.com \
    --cc=23397@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.