From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#15841: Display bugs with cache-long-lines non-nil Date: Fri, 15 Nov 2013 18:34:05 +0200 Message-ID: <838uwpipz6.fsf@gnu.org> References: <871u2xf9st.fsf@gmail.com> <9jiow9uhoa.fsf@fencepost.gnu.org> <87wqkopylw.fsf@gmail.com> <87bo20fh3h.fsf@web.de> <834n7q95d5.fsf@gnu.org> <87r4aqww3j.fsf@nbtrap.com> <83r4aq3s4r.fsf@gnu.org> <87fvr3ni2o.fsf@rosalinde.fritz.box> <877gceo3n9.fsf@rosalinde.fritz.box> <87mwla6inw.fsf@rosalinde.fritz.box> <83txfh1t0b.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1384533315 22256 80.91.229.3 (15 Nov 2013 16:35:15 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Nov 2013 16:35:15 +0000 (UTC) Cc: 15841@debbugs.gnu.org To: stephen.berman@gmx.net Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 15 17:35:17 2013 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 1VhMMX-0006au-1U for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 17:35:17 +0100 Original-Received: from localhost ([::1]:32768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhMMW-0004eD-Iv for geb-bug-gnu-emacs@m.gmane.org; Fri, 15 Nov 2013 11:35:16 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33703) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhMMO-0004cy-HT for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 11:35:14 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VhMMI-00058u-Ii for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 11:35:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42105) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VhMMI-00057u-7V for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 11:35:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VhMMH-0007ZL-Lx for bug-gnu-emacs@gnu.org; Fri, 15 Nov 2013 11:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 15 Nov 2013 16:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15841 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15841-submit@debbugs.gnu.org id=B15841.138453327129053 (code B ref 15841); Fri, 15 Nov 2013 16:35:01 +0000 Original-Received: (at 15841) by debbugs.gnu.org; 15 Nov 2013 16:34:31 +0000 Original-Received: from localhost ([127.0.0.1]:56124 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VhMLn-0007YX-3n for submit@debbugs.gnu.org; Fri, 15 Nov 2013 11:34:31 -0500 Original-Received: from mtaout23.012.net.il ([80.179.55.175]:36891) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VhMLk-0007YJ-4u for 15841@debbugs.gnu.org; Fri, 15 Nov 2013 11:34:29 -0500 Original-Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MWB00200CAWCA00@a-mtaout23.012.net.il> for 15841@debbugs.gnu.org; Fri, 15 Nov 2013 18:34:21 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MWB00244CP79E80@a-mtaout23.012.net.il>; Fri, 15 Nov 2013 18:34:20 +0200 (IST) In-reply-to: <83txfh1t0b.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:80603 Archived-At: > Date: Tue, 12 Nov 2013 18:31:32 +0200 > From: Eli Zaretskii > Cc: 15841@debbugs.gnu.org > > In any case, I already traced through the code that is involved, and > the immediate reason for the assertion violation is that the cache > isn't being updated wrt changes in buffer size (which are caused by > decoding the stuff brought in by 'ls'). However, a naive attempt to > force such updates didn't solve the whole problem: the aborts are > gone, but the infloop is still there, and also other minor display > issues. So I guess there's another factor at work there... I think I might have found a solution for this. Could you please run with the patch below for a while, and see if it gives good results? === modified file 'src/coding.c' --- src/coding.c 2013-10-08 06:40:09 +0000 +++ src/coding.c 2013-11-15 16:27:56 +0000 @@ -9358,6 +9358,14 @@ code_convert_region (Lisp_Object start, setup_coding_system (coding_system, &coding); coding.mode |= CODING_MODE_LAST_BLOCK; + if (BUFFERP (dst_object) && !EQ (dst_object, src_object)) + { + struct buffer *buf = XBUFFER (dst_object); + ptrdiff_t buf_pt = BUF_PT (buf); + + invalidate_buffer_caches (buf, buf_pt, buf_pt); + } + if (encodep) encode_coding_object (&coding, src_object, from, from_byte, to, to_byte, dst_object); @@ -9447,6 +9455,15 @@ code_convert_string (Lisp_Object string, coding.mode |= CODING_MODE_LAST_BLOCK; chars = SCHARS (string); bytes = SBYTES (string); + + if (BUFFERP (dst_object)) + { + struct buffer *buf = XBUFFER (dst_object); + ptrdiff_t buf_pt = BUF_PT (buf); + + invalidate_buffer_caches (buf, buf_pt, buf_pt); + } + if (encodep) encode_coding_object (&coding, string, 0, 0, chars, bytes, dst_object); else === modified file 'src/insdel.c' --- src/insdel.c 2013-11-11 05:18:53 +0000 +++ src/insdel.c 2013-11-15 16:27:56 +0000 @@ -993,6 +993,11 @@ insert_from_gap (ptrdiff_t nchars, ptrdi if (NILP (BVAR (current_buffer, enable_multibyte_characters))) nchars = nbytes; + /* No need to call prepare_to_modify_buffer, since this is called + from places that replace some region with a different text, so + prepare_to_modify_buffer was already called by the deletion part + of this dance. */ + invalidate_buffer_caches (current_buffer, GPT, GPT); record_insert (GPT, nchars); MODIFF++; @@ -1869,19 +1874,26 @@ prepare_to_modify_buffer (ptrdiff_t star ptrdiff_t *preserve_ptr) { prepare_to_modify_buffer_1 (start, end, preserve_ptr); + invalidate_buffer_caches (current_buffer, start, end); +} - if (current_buffer->newline_cache) - invalidate_region_cache (current_buffer, - current_buffer->newline_cache, - start - BEG, Z - end); - if (current_buffer->width_run_cache) - invalidate_region_cache (current_buffer, - current_buffer->width_run_cache, - start - BEG, Z - end); - if (current_buffer->bidi_paragraph_cache) - invalidate_region_cache (current_buffer, - current_buffer->bidi_paragraph_cache, - start - BEG, Z - end); +/* Invalidate the caches maintained by the buffer BUF, if any, for the + region between buffer positions START and END. */ +void +invalidate_buffer_caches (struct buffer *buf, ptrdiff_t start, ptrdiff_t end) +{ + if (buf->newline_cache) + invalidate_region_cache (buf, + buf->newline_cache, + start - BUF_BEG (buf), BUF_Z (buf) - end); + if (buf->width_run_cache) + invalidate_region_cache (buf, + buf->width_run_cache, + start - BUF_BEG (buf), BUF_Z (buf) - end); + if (buf->bidi_paragraph_cache) + invalidate_region_cache (buf, + buf->bidi_paragraph_cache, + start - BUF_BEG (buf), BUF_Z (buf) - end); } /* These macros work with an argument named `preserve_ptr' === modified file 'src/lisp.h' --- src/lisp.h 2013-11-15 08:18:37 +0000 +++ src/lisp.h 2013-11-15 16:27:56 +0000 @@ -3486,6 +3486,7 @@ extern Lisp_Object del_range_2 (ptrdiff_ extern void modify_text (ptrdiff_t, ptrdiff_t); extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *); extern void prepare_to_modify_buffer_1 (ptrdiff_t, ptrdiff_t, ptrdiff_t *); +extern void invalidate_buffer_caches (struct buffer *, ptrdiff_t, ptrdiff_t); extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t); extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t);