From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Raeburn Newsgroups: gmane.emacs.bugs Subject: bug#23397: 25.0.92; assertion failure auto-reverting a file being overwritten Date: Tue, 03 May 2016 17:04:24 -0400 Message-ID: <6e8tzqdfaf.fsf@just-testing.permabit.com> References: <6epot9crti.fsf@just-testing.permabit.com> <83vb2wl83m.fsf@gnu.org> <6efuu0chsv.fsf@just-testing.permabit.com> <83d1p3kw9y.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1462309544 7012 80.91.229.3 (3 May 2016 21:05:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 May 2016 21:05:44 +0000 (UTC) Cc: 23397@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 03 23:05:33 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1axhVb-0001wP-Vt for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 May 2016 23:05:32 +0200 Original-Received: from localhost ([::1]:43421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axhVY-0002LG-1G for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 May 2016 17:05:28 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axhVO-00025o-G1 for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 17:05:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axhVC-0005WV-KN for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 17:05:13 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51762) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axhVB-0005Up-EB for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 17:05:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1axhV7-0003gN-Vw for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 17:05:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ken Raeburn Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 May 2016 21:05:01 +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.146230947314115 (code B ref 23397); Tue, 03 May 2016 21:05:01 +0000 Original-Received: (at 23397) by debbugs.gnu.org; 3 May 2016 21:04:33 +0000 Original-Received: from localhost ([127.0.0.1]:35866 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axhUe-0003fa-SQ for submit@debbugs.gnu.org; Tue, 03 May 2016 17:04:33 -0400 Original-Received: from mail-qg0-f52.google.com ([209.85.192.52]:33938) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axhUd-0003fN-41 for 23397@debbugs.gnu.org; Tue, 03 May 2016 17:04:31 -0400 Original-Received: by mail-qg0-f52.google.com with SMTP id 90so14347588qgz.1 for <23397@debbugs.gnu.org>; Tue, 03 May 2016 14:04:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=permabit.com; s=google; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Bgc7yvjMFMKYUg/3qV52qeobwHKAeTlTwSSHOaRdcg0=; b=a7ZHDYSiMULP54EJW9OdOTvAE+l/OANQIsFPg2vcbYMmL20pOKLbI69i+BN0wDQNMN VOBEHIBaSFy3eO0n1/27tGFkGWcX3XS4smksti04hnVOJ8FIl4DitoiykXJlnfjarhJB qQx/zHuIbH+h/Ws9l7kYvqKmUSRdaFCbLkv0k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=Bgc7yvjMFMKYUg/3qV52qeobwHKAeTlTwSSHOaRdcg0=; b=lodzUWgWNblLkI81m99WxhURtWeoC2QJjib0TzIXS1sXTezdsxhuK4/ZEz4FWs/HlU xW6r//9Oy1KRk2g2bkwMhcbXKZe0TFPrnEebcF5YE/WSswOU56xsfkRhNLia1sAEKXFN +MNSwO7Y8SD0ZF4YlI9yo/C31hvN1WqsPgSHPyCDveh/4GVRYHCuIVGEs7EQYenCbdwW Y1b5sdZonIPwdwNbFv/X9+DGigAg3m+ZJH31llmN3sDdV1cKp1xrlAnj9E8C5meH0mit /xYUrSqpFHo11C1gfPpJixisCzL5T7+iXrwWkFgZm8OBVkJuhsWxsnAsm1t8m0VgBo3W +8nA== X-Gm-Message-State: AOPr4FXFZ/WnDDpVo2rJ4fjRpL3kc6sv6OKMGoj8ZT6JDx7ad0dq8svIUEKPZ6Dfse8nTC3F X-Received: by 10.140.89.202 with SMTP id v68mr4865901qgd.95.1462309465818; Tue, 03 May 2016 14:04:25 -0700 (PDT) Original-Received: from just-testing.permabit.com (vpn.permabit.com. [66.202.84.2]) by smtp.gmail.com with ESMTPSA id x189sm99898qhb.43.2016.05.03.14.04.24 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 03 May 2016 14:04:24 -0700 (PDT) In-Reply-To: <83d1p3kw9y.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 03 May 2016 18:15:37 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.92 (gnu/linux) 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:117694 Archived-At: Eli Zaretskii writes: > That is still better than aborting, right? Of course. But it seems to me we should have the information we need to keep the Emacs processing self-consistent whether we iterate or not. Other code in the function already clearly expects that the number of bytes we can read may be different from st_size. (Arguably, in case we're trying to preserve point or markers in a later part of the file than might have been rewritten so far, it might be desirable for insert-file-contents to restart or pause briefly and retry reading more content if it detects a change, but I think that's mostly a separate question.) I've finally reproduced the problem. A key issue was that the whole block containing the failing code would be skipped by the conditional below if the coding system were "undecided", which seems to be the norm in my testing with "emacs -Q", but not in my working environment for whatever reason; maybe one of the minor modes I've loaded is setting a more specific coding system. if (!NILP (replace) && BEGV < ZV && (NILP (coding_system) || ! CODING_REQUIRE_DECODING (&coding))) If the coding system is "undecided-unix", we enter this block, and I can get it to blow up. Recipe: Get two similar files differing in the middle; I started with emacs-25 charset.h: cp .../src/charset.h file.h sed -e 400,499s/a/b/g < file.h > file2.h Set a breakpoint just after the fstat call in Finsert_file_contents, run emacs -Q, and read in file.h (continuing whenever the breakpoint is hit). Turn on auto-revert-mode in the buffer. Set the coding system with "C-x RET f" to "undecided-unix". That marks the buffer as modified, so clear that by saving the file. Copy file2.h over file.h, and when the breakpoint is triggered, change st.st_size to zero, to simulate rereading before the file overwriting has finished, and continue. My debugging printfs show that an out-of-range same_at_end is generated as in my original case: (gdb) c Continuing. Finsert_file_contents:3871: same_at_start=13993 same_at_end=17747 st_size=0 ZV=19498 => overlap=15743 => new same_at_end=33490 ../../src/marker.c:297: Emacs fatal error: assertion failed: BUF_BEG_BYTE (b) <= bytepos && bytepos <= BUF_Z_BYTE (b)