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#12745: crash in bidi_pop_it during (idle) redisplay Date: Sat, 03 Nov 2012 11:31:54 +0200 Message-ID: <83boff58xh.fsf@gnu.org> References: <508CA6FC.4070203@cs.ucla.edu> <508CE3B0.2030809@cs.ucla.edu> <83lieq8q91.fsf@gnu.org> <83fw4y8jgd.fsf@gnu.org> <838vap8aq8.fsf@gnu.org> <837gq987yv.fsf@gnu.org> <834nld81sj.fsf@gnu.org> <83mwz37sq5.fsf@gnu.org> <83lien7k0b.fsf@gnu.org> <83fw4u7ifr.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1351935196 13355 80.91.229.3 (3 Nov 2012 09:33:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 Nov 2012 09:33:16 +0000 (UTC) Cc: alptekin.aker@gmail.com, 12745@debbugs.gnu.org To: ami@fischman.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Nov 03 10:33:25 2012 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 1TUa6V-0006A7-O4 for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Nov 2012 10:33:23 +0100 Original-Received: from localhost ([::1]:40005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUa6M-0004Id-TR for geb-bug-gnu-emacs@m.gmane.org; Sat, 03 Nov 2012 05:33:14 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:36992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUa6J-0004IP-OG for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 05:33:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TUa6G-00029c-W6 for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 05:33:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:36423) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TUa6G-00029S-Ss for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 05:33:08 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TUa93-00076y-Qp for bug-gnu-emacs@gnu.org; Sat, 03 Nov 2012 05:36:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 03 Nov 2012 09:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12745 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12745-submit@debbugs.gnu.org id=B12745.135193530327266 (code B ref 12745); Sat, 03 Nov 2012 09:36:01 +0000 Original-Received: (at 12745) by debbugs.gnu.org; 3 Nov 2012 09:35:03 +0000 Original-Received: from localhost ([127.0.0.1]:46674 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUa87-00075j-GY for submit@debbugs.gnu.org; Sat, 03 Nov 2012 05:35:03 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:64880) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TUa84-00075I-Gm for 12745@debbugs.gnu.org; Sat, 03 Nov 2012 05:35:01 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MCW00A00NPND900@a-mtaout22.012.net.il> for 12745@debbugs.gnu.org; Sat, 03 Nov 2012 11:32:05 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MCW00A5XNTG9E50@a-mtaout22.012.net.il>; Sat, 03 Nov 2012 11:32:05 +0200 (IST) In-reply-to: <83fw4u7ifr.fsf@gnu.org> X-012-Sender: halo1@inter.net.il X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.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:66371 Archived-At: > Date: Wed, 31 Oct 2012 17:46:48 +0200 > From: Eli Zaretskii > Cc: alptekin.aker@gmail.com, 12745@debbugs.gnu.org > > I will meanwhile fix init_from_display_pos, because it's certainly > looks broken, and could well be the root cause for this. Now done in revision 110767 on the emacs-24 branch. Will appear on the trunk on the next merge. The patch is below, FYI. === modified file 'src/xdisp.c' --- src/xdisp.c 2012-10-20 21:30:51 +0000 +++ src/xdisp.c 2012-11-03 09:25:34 +0000 @@ -928,6 +928,7 @@ static enum move_it_result move_it_in_display_line_to (struct it *, ptrdiff_t, int, enum move_operation_enum); void move_it_vertically_backward (struct it *, int); +static void get_visually_first_element (struct it *); static void init_to_row_start (struct it *, struct window *, struct glyph_row *); static int init_to_row_end (struct it *, struct window *, @@ -3113,6 +3114,40 @@ init_from_display_pos (struct it *it, st eassert (STRINGP (it->string)); it->current.string_pos = pos->string_pos; it->method = GET_FROM_STRING; + it->end_charpos = SCHARS (it->string); + /* Set up the bidi iterator for this overlay string. */ + if (it->bidi_p) + { + it->bidi_it.string.lstring = it->string; + it->bidi_it.string.s = NULL; + it->bidi_it.string.schars = SCHARS (it->string); + it->bidi_it.string.bufpos = it->overlay_strings_charpos; + it->bidi_it.string.from_disp_str = it->string_from_display_prop_p; + it->bidi_it.string.unibyte = !it->multibyte_p; + bidi_init_it (IT_STRING_CHARPOS (*it), IT_STRING_BYTEPOS (*it), + FRAME_WINDOW_P (it->f), &it->bidi_it); + + /* Synchronize the state of the bidi iterator with + pos->string_pos. For any string position other than + zero, this will be done automagically when we resume + iteration over the string and get_visually_first_element + is called. But if string_pos is zero, and the string is + to be reordered for display, we need to resync manually, + since it could be that the iteration state recorded in + pos ended at string_pos of 0 moving backwards in string. */ + if (CHARPOS (pos->string_pos) == 0) + { + get_visually_first_element (it); + if (IT_STRING_CHARPOS (*it) != 0) + do { + /* Paranoia. */ + eassert (it->bidi_it.charpos < it->bidi_it.string.schars); + bidi_move_to_visually_next (&it->bidi_it); + } while (it->bidi_it.charpos != 0); + } + eassert (IT_STRING_CHARPOS (*it) == it->bidi_it.charpos + && IT_STRING_BYTEPOS (*it) == it->bidi_it.bytepos); + } } if (CHARPOS (pos->string_pos) >= 0) @@ -3122,6 +3157,9 @@ init_from_display_pos (struct it *it, st IT should already be filled with that string. */ it->current.string_pos = pos->string_pos; eassert (STRINGP (it->string)); + if (it->bidi_p) + bidi_init_it (IT_STRING_CHARPOS (*it), IT_STRING_BYTEPOS (*it), + FRAME_WINDOW_P (it->f), &it->bidi_it); } /* Restore position in display vector translations, control