Subject: Re: bug#39658: 26.3; can't edit file with terminal escape sequences

From: Mattias Engdegård <[email-masked]>
Date: Tue, 18 Feb 2020 23:09:06 +0100

On Tue, Feb 18, 2020 at 06:08:55PM +0200, Eli Zaretskii wrote:

> If someone wants to investigate this case, I'd start with visiting the
> file after "M-x profiler-start".  Then look at the hot spot(s).

The profiler didn't show anything, but according to gdb/lldb, there is something going on in the bidi bracket code. Every time I hook on a debugger, the stack is like this:

  * frame #0: 0x000000010dcc41b2 emacs`bidi_find_bracket_pairs(bidi_it=0x00007ffee1fdd610) at bidi.c:2572:12 [opt]
    frame #1: 0x000000010dcc3c1f emacs`bidi_resolve_brackets(bidi_it=0x00007ffee1fdd610) at bidi.c:2856:13 [opt]
    frame #2: 0x000000010dcc1556 emacs`bidi_level_of_next_char [inlined] bidi_resolve_neutral(bidi_it=<unavailable>) at bidi.c:2957:22 [opt]
    frame #3: 0x000000010dcc154e emacs`bidi_level_of_next_char [inlined] bidi_type_of_next_char at bidi.c:3162 [opt]
    frame #4: 0x000000010dcc154e emacs`bidi_level_of_next_char(bidi_it=0x00007ffee1fdd610) at bidi.c:3229 [opt]
    frame #5: 0x000000010dcc0d27 emacs`bidi_move_to_visually_next(bidi_it=0x00007ffee1fdd610) at bidi.c:3422:15 [opt]
    frame #6: 0x000000010dc394af emacs`set_iterator_to_next(it=0x00007ffee1fdcc20, reseat_p=<unavailable>) at xdisp.c:7805:8 [opt]
    frame #7: 0x000000010dc39701 emacs`set_iterator_to_next(it=0x00007ffee1fdcc20, reseat_p=<unavailable>) at xdisp.c:7877:8 [opt]
    frame #8: 0x000000010dc49c5c emacs`display_line(it=<unavailable>, cursor_vpos=<unavailable>) at xdisp.c:23590:2 [opt]
    frame #9: 0x000000010dc47d99 emacs`try_window(window=0x00007fccf791f835, pos=<unavailable>, flags=1) at xdisp.c:19062:11 [opt]
    frame #10: 0x000000010dc71158 emacs`redisplay_window(window=0x00007fccf791f835, just_this_one_p=<unavailable>) at xdisp.c:18480:8 [opt]
    frame #11: 0x000000010dc6f156 emacs`redisplay_window_0(window=<unavailable>) at xdisp.c:16194:5 [opt]
    frame #12: 0x000000010dd64e3f emacs`internal_condition_case_1(bfun=<unavailable>, arg=0x00007fccf791f835, handlers=0x000000010f9df353, hfun=(emacs`redisplay_window_error at xdisp.c:16185)) at eval.c:1379:25 [opt]
    frame #13: 0x000000010dc6e82c emacs`redisplay_windows(window=0x00007fccf791f835) at xdisp.c:16174:4 [opt]
    frame #14: 0x000000010dc45016 emacs`redisplay_internal at xdisp.c:15642:5 [opt]

Test case: perl -le 'print "[" x 60000' > somefile
There seems to be a threshold at around 50000 characters.