From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#23397: 25.0.92; assertion failure auto-reverting a file being overwritten Date: Sat, 16 Jun 2018 17:45:36 -0400 Message-ID: <87zhzutngf.fsf@gmail.com> References: <6epot9crti.fsf@just-testing.permabit.com> <83vb2wl83m.fsf@gnu.org> <6efuu0chsv.fsf@just-testing.permabit.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1529185448 18390 195.159.176.226 (16 Jun 2018 21:44:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 16 Jun 2018 21:44:08 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: 23397@debbugs.gnu.org To: Ken Raeburn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 16 23:44:04 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUIzL-0004fL-5d for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Jun 2018 23:44:03 +0200 Original-Received: from localhost ([::1]:52960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUJ1R-0003Z3-O8 for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Jun 2018 17:46:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUJ1K-0003Xl-0l for bug-gnu-emacs@gnu.org; Sat, 16 Jun 2018 17:46:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUJ1G-0002GE-VD for bug-gnu-emacs@gnu.org; Sat, 16 Jun 2018 17:46:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:44276) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUJ1G-0002Fx-QG for bug-gnu-emacs@gnu.org; Sat, 16 Jun 2018 17:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fUJ1G-0004uX-9g for bug-gnu-emacs@gnu.org; Sat, 16 Jun 2018 17:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Jun 2018 21:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23397 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23397-submit@debbugs.gnu.org id=B23397.152918554718855 (code B ref 23397); Sat, 16 Jun 2018 21:46:02 +0000 Original-Received: (at 23397) by debbugs.gnu.org; 16 Jun 2018 21:45:47 +0000 Original-Received: from localhost ([127.0.0.1]:52173 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUJ11-0004ty-C8 for submit@debbugs.gnu.org; Sat, 16 Jun 2018 17:45:47 -0400 Original-Received: from mail-io0-f175.google.com ([209.85.223.175]:36306) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUJ0y-0004tf-Gx; Sat, 16 Jun 2018 17:45:45 -0400 Original-Received: by mail-io0-f175.google.com with SMTP id k3-v6so13715073iog.3; Sat, 16 Jun 2018 14:45:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=b6MZtqpRF7CshnhOaf8OOEovMs8DPUmNcfmDTJgKDFc=; b=AsrMRkESSjAvPLVxiQXb436PjHGj6bDuQzaKGTyYKLqfnsDaJlim1DErcrobaPqe++ BI5/nQoFrvRW5xKBdv9VbSivB2BpIOqfLgliU0WdUzFh9LE+fSzIxoTI9b5Xi7TOnp2q qM60PN3KQ7l8wZWyK6fW9vLcS7a/mFaOjcnpDHd/xKQDDUKnMfMXiFKr33pUU+HHRClk ir0haOlP7O4OUjnuJ3igysA3aLFOZU7OLSdEmKWrMi/6uUa8SFlFXjdSrHs4dZS33xIa Z04qSF9H2Ag6rtnrwriysd0LRYmQRhY6sikxsxt3JlEd/Z8QHVjaR8cGT5JZpj4n7RuE oKBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=b6MZtqpRF7CshnhOaf8OOEovMs8DPUmNcfmDTJgKDFc=; b=NgjL7qYqPuOAHaFLtOymnXnS8jpCaGFKQZnW6JY2vE4GruRyrT1FcE3wnMTMvZWVYg +A7FNS4eeOB5o9S0KyiOLsibk+2w62yPmuIuVeKVe53XlxzNDCsyE8l+ZjOw6ldylZMJ WTFDAQOhlftuINA0L72KJdyhsXXvDzK2kazE5baicULkTZt1xaZjmM0asHZKJfxE83Xx FoqweS9nb5Y1MnFRQZZlCqlkYuFncgijDr33hKlgdJm/FlXT8/2KHCLmLTX7ph1cPlPy JFr95RiGj9hwsIwv849VDDlme/boUGguk0kufaS5V9HArqEhAOkUgeNf6Ozlacc9kDE9 GLAA== X-Gm-Message-State: APt69E19yocytaPDTertrlh+yt6VCm+W8hShCpKBjx+SZ7qvrVyLJni9 Qw+sOHxgaHXRXc8cOtx4S66TXQ== X-Google-Smtp-Source: ADUXVKIsiTnBJqgmpNPq+NH7jSDNtink3/WRVEOqkA6lDtRlROZBzRuuZfX0logONilAiN23TXcFiQ== X-Received: by 2002:a6b:3c11:: with SMTP id k17-v6mr5464022iob.92.1529185538609; Sat, 16 Jun 2018 14:45:38 -0700 (PDT) Original-Received: from zebian (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.googlemail.com with ESMTPSA id y18-v6sm4326042ioa.10.2018.06.16.14.45.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 16 Jun 2018 14:45:38 -0700 (PDT) In-Reply-To: <6efuu0chsv.fsf@just-testing.permabit.com> (Ken Raeburn's message of "Mon, 02 May 2016 16:43:12 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:147540 Archived-At: found 23397 26.1 tags 23397 + confirmed quit Ken Raeburn 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);