Subject: bug#71289: 30.0.50; cmcheckmagic aborts when tty_write_glyphs writes "Garbage collecting..." in some cases

From: Daniel Clemente <[email-masked]>
Date: Wed, 5 Jun 2024 13:50:48 +0000

> Please update from Git before trying anything else wrt this bug.  I
> installed a simple baind-aid that is intended to avoid problems with
> frame dimensions while we have an unhandled SIGWINCH.

Thanks for the code.

With it (running on 799f78a92c6c31f4d181390523b83d036020ede1 with no
other changes), I still see the same types of crash that I already
reported: in tty_write_glyphs (see BT1 below) and in
build_frame_matrix_from_leaf_window (see BT2 below).
However they don't mention GC now.

BT1

[Detaching after vfork from child process 2902]
[Detaching after vfork from child process 2903]
[Detaching after vfork from child process 3039]
Garbage collecting...
When done with this frame, type C-x 5 0

Breakpoint 1, terminate_due_to_signal (sig=6, backtrace_limit=40) at emacs.c:443
443      signal (sig, SIG_DFL);
(gdb) cont
Continuing.
Fatal error 6: Aborted
Backtrace:
/opt/dc/emacs/bin/emacs(+0x169205)[0x5555556bd205]
/opt/dc/emacs/bin/emacs(+0x134500)[0x555555688500]
/opt/dc/emacs/bin/emacs(+0x169273)[0x5555556bd273]
/opt/dc/emacs/bin/emacs(+0x11511e)[0x55555566911e]
/opt/dc/emacs/bin/emacs(+0x119632)[0x55555566d632]
/opt/dc/emacs/bin/emacs(+0x1239c6)[0x5555556779c6]
/opt/dc/emacs/bin/emacs(+0x3d8f7)[0x5555555918f7]
/opt/dc/emacs/bin/emacs(+0x3c9e2)[0x5555555909e2]
/opt/dc/emacs/bin/emacs(+0x38f4c)[0x55555558cf4c]
/opt/dc/emacs/bin/emacs(+0x7b5c9)[0x5555555cf5c9]
/opt/dc/emacs/bin/emacs(+0x7befd)[0x5555555cfefd]
/opt/dc/emacs/bin/emacs(+0x299dbc)[0x5555557eddbc]
/opt/dc/emacs/bin/emacs(+0x40ee0)[0x555555594ee0]
/opt/dc/emacs/bin/emacs(+0x1412a8)[0x5555556952a8]
/opt/dc/emacs/bin/emacs(+0x152857)[0x5555556a6857]
/opt/dc/emacs/bin/emacs(+0x13cf3f)[0x555555690f3f]
/opt/dc/emacs/bin/emacs(+0x21873d)[0x55555576c73d]
/opt/dc/emacs/bin/emacs(+0x13c6ee)[0x5555556906ee]
/opt/dc/emacs/bin/emacs(+0x217b6a)[0x55555576bb6a]
/opt/dc/emacs/bin/emacs(+0x13c680)[0x555555690680]
/opt/dc/emacs/bin/emacs(+0x13ba5d)[0x55555568fa5d]
/opt/dc/emacs/bin/emacs(+0x13bc89)[0x55555568fc89]
/opt/dc/emacs/bin/emacs(+0x1376f0)[0x55555568b6f0]
/lib/x86_64-linux-gnu/libc.so.6(+0x2724a)[0x7ffff544624a]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x85)[0x7ffff5446305]
/opt/dc/emacs/bin/emacs(+0x30831)[0x555555584831]

Program received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6,
    no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
44    ./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0  __pthread_kill_implementation (threadid=<optimized out>,
signo=signo@entry=6,
    no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
#1  0x00007ffff54a9e8f in __pthread_kill_internal (signo=6,
threadid=<optimized out>)
    at ./nptl/pthread_kill.c:78
#2  0x00007ffff545afb2 in __GI_raise (sig=6) at ../sysdeps/posix/raise.c:26
#3  0x000055555568854c in terminate_due_to_signal (sig=6, backtrace_limit=40)
    at emacs.c:480
#4  0x00005555556bd273 in emacs_abort () at sysdep.c:2391
#5  0x000055555566911e in cmcheckmagic (tty=0x55556112ed70) at cm.c:121
#6  0x000055555566d632 in tty_write_glyphs (f=0x55556112e470,
string=0x55556150b540,
    len=80) at term.c:819
#7  0x00005555556779c6 in write_glyphs (f=0x55556112e470,
string=0x55556150a640, len=80)
    at terminal.c:163
#8  0x00005555555918f7 in update_frame_line (f=0x55556112e470, vpos=13,
    updating_menu_p=false) at dispnew.c:5320
#9  0x00005555555909e2 in update_frame_1 (f=0x55556112e470, force_p=true,
    inhibit_id_p=false, set_cursor_p=true, updating_menu_p=false) at
dispnew.c:4979
#10 0x000055555558cf4c in update_frame (f=0x55556112e470, force_p=true,
    inhibit_hairy_id_p=false) at dispnew.c:3345
#11 0x00005555555cf5c9 in redisplay_internal () at xdisp.c:17464
#12 0x00005555555cfefd in redisplay_preserve_echo_area (from_where=11)
at xdisp.c:17747
#13 0x00005555557eddbc in wait_reading_process_output (time_limit=127, nsecs=0,
    read_kbd=-1, do_display=true, wait_for_cell=XIL(0), wait_proc=0x0,
just_wait_proc=0)
    at process.c:5585
#14 0x0000555555594ee0 in sit_for (timeout=make_fixnum(127), reading=true,
    display_option=1) at dispnew.c:6329
#15 0x00005555556952a8 in read_char (commandflag=1, map=XIL(0x555563b0c373),
    prev_event=XIL(0), used_mouse_menu=0x7fffffffd6df, end_time=0x0)
at keyboard.c:2923
#16 0x00005555556a6857 in read_key_sequence (keybuf=0x7fffffffd8f0,
prompt=XIL(0),
    dont_downcase_last=false, can_return_switch_frame=true,
fix_current_buffer=true,
    prevent_redisplay=false, disable_text_conversion_p=false) at
keyboard.c:10728
#17 0x0000555555690f3f in command_loop_1 () at keyboard.c:1429
#18 0x000055555576c73d in internal_condition_case (bfun=0x555555690b10
<command_loop_1>,
    handlers=XIL(0x90), hfun=0x55555568ffbb <cmd_error>) at eval.c:1613
#19 0x00005555556906ee in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1168
#20 0x000055555576bb6a in internal_catch (tag=XIL(0xfc90),
    func=0x5555556906c4 <command_loop_2>, arg=XIL(0x90)) at eval.c:1292
#21 0x0000555555690680 in command_loop () at keyboard.c:1146
#22 0x000055555568fa5d in recursive_edit_1 () at keyboard.c:754
#23 0x000055555568fc89 in Frecursive_edit () at keyboard.c:837
#24 0x000055555568b6f0 in main (argc=2, argv=0x7fffffffdf18) at emacs.c:2625

Lisp Backtrace:
"redisplay_internal (C function)" (0x0)

BT2:

dispnew.c:2649: Emacs fatal error: assertion failed:
delayed_size_change || glyph_row_slice_p (window_row, frame_row)

Breakpoint 1, terminate_due_to_signal (sig=6,
backtrace_limit=2147483647) at emacs.c:443
443  signal (sig, SIG_DFL);
(gdb) bt
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:443
#1  0x0000555555735b51 in die (
    msg=0x55555584e838 "delayed_size_change || glyph_row_slice_p
(window_row, frame_row)",
    file=0x55555584e231 "dispnew.c", line=2649) at alloc.c:8082
#2  0x000055555558b5fe in build_frame_matrix_from_leaf_window
(frame_matrix=0x5555590db110,
    w=0x555559588548) at dispnew.c:2649
#3  0x000055555558b10f in build_frame_matrix_from_window_tree
(matrix=0x5555590db110,
    w=0x555559588548) at dispnew.c:2538
#4  0x000055555558b0a4 in build_frame_matrix (f=0x5555593233b0) at
dispnew.c:2522
#5  0x000055555558cf82 in update_frame (f=0x5555593233b0,
force_p=true, inhibit_hairy_id_p=false)
    at dispnew.c:3338
#6  0x00005555555cf9fe in redisplay_internal () at xdisp.c:17501
#7  0x00005555555cd5d3 in redisplay () at xdisp.c:16599
#8  0x000055555569522f in read_char (commandflag=1,
map=XIL(0x555559d4aca3), prev_event=XIL(0),
    used_mouse_menu=0x7fffffffd6df, end_time=0x0) at keyboard.c:2678
#9  0x00005555556a727f in read_key_sequence (keybuf=0x7fffffffd8f0,
prompt=XIL(0),
    dont_downcase_last=false, can_return_switch_frame=true,
fix_current_buffer=true,
    prevent_redisplay=false, disable_text_conversion_p=false) at
keyboard.c:10728
#10 0x0000555555691967 in command_loop_1 () at keyboard.c:1429
#11 0x000055555576d165 in internal_condition_case (bfun=0x555555691538
<command_loop_1>,
    handlers=XIL(0x90), hfun=0x5555556909e3 <cmd_error>) at eval.c:1613
#12 0x0000555555691116 in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1168
#13 0x000055555576c592 in internal_catch (tag=XIL(0xfc90),
func=0x5555556910ec <command_loop_2>,
    arg=XIL(0x90)) at eval.c:1292
#14 0x00005555556910a8 in command_loop () at keyboard.c:1146
#15 0x0000555555690485 in recursive_edit_1 () at keyboard.c:754
#16 0x00005555556906b1 in Frecursive_edit () at keyboard.c:837
#17 0x000055555568c118 in main (argc=2, argv=0x7fffffffdf18) at emacs.c:2625

Lisp Backtrace:
"redisplay_internal (C function)" (0x0)
(gdb) bt full
#0  terminate_due_to_signal (sig=6, backtrace_limit=2147483647) at emacs.c:443
No locals.
#1  0x0000555555735b51 in die (
    msg=0x55555584e838 "delayed_size_change || glyph_row_slice_p
(window_row, frame_row)",
    file=0x55555584e231 "dispnew.c", line=2649) at alloc.c:8082
No locals.
#2  0x000055555558b5fe in build_frame_matrix_from_leaf_window
(frame_matrix=0x5555590db110,
    w=0x555559588548) at dispnew.c:2649
        frame_row = 0x55555ea81bc0
        window_row = 0x55555ad0f560
        current_row_p = false
        window_matrix = 0x5555606d5ca0
        window_y = 0
        frame_y = 6
        right_border_glyph = {
          ch = 0,
          face_id = 0
        }
#3  0x000055555558b10f in build_frame_matrix_from_window_tree
(matrix=0x5555590db110,
    w=0x555559588548) at dispnew.c:2538
No locals.
#4  0x000055555558b0a4 in build_frame_matrix (f=0x5555593233b0) at
dispnew.c:2522
        i = 7
#5  0x000055555558cf82 in update_frame (f=0x5555593233b0,
force_p=true, inhibit_hairy_id_p=false)
    at dispnew.c:3338
        paused_p = false
        root_window = 0x55555a922718
#6  0x00005555555cf9fe in redisplay_internal () at xdisp.c:17501
        gcscrollbars = true
        f_redisplay_flag = true
        f = 0x5555593233b0
        w = 0x55555979b9b8
        sw = 0x55555979b9b8
        fr = 0x5555593233b0
        pending = false
        must_finish = true
        match_p = true
        tlbufpos = {
          charpos = 0,
          bytepos = 2398
        }
        tlendpos = {
          charpos = 612164,
          bytepos = 621585
        }
        number_of_visible_frames = 2
        sf = 0x5555593233b0
        polling_stopped_here = true
        tail = XIL(0x5555594a6dd3)
        frame = XIL(0x5555593233b5)
        MAX_HSCROLL_RETRIES = MAX_HSCROLL_RETRIES
        hscroll_retries = 0
        MAX_GARBAGED_FRAME_RETRIES = MAX_GARBAGED_FRAME_RETRIES
        garbaged_frame_retries = 0
        consider_all_windows_p = true
        update_miniwindow_p = true
        count = {
          bytes = 96
        }
#7  0x00005555555cd5d3 in redisplay () at xdisp.c:16599
No locals.
#8  0x000055555569522f in read_char (commandflag=1,
map=XIL(0x555559d4aca3), prev_event=XIL(0),
    used_mouse_menu=0x7fffffffd6df, end_time=0x0) at keyboard.c:2678
--Type <RET> for more, q to quit, c to continue without paging--
        echo_current = true
        c = XIL(0)
        local_getcjmp = {{
            __jmpbuf = {93825042211488, 93825034828643,
140737488344272, 93824994276319, 48,
              93825042211488, 93825002663072, 0},
            __mask_was_saved = 0,
            __saved_mask = {
              __val = {140737488344320, 93824993654404,
93825034828611, 140737488344480,
                93824993676685, 93825002663072, 0, 0, 140737488344384,
93824994411239, 1471451152,
                140737488344480, 93824994455892, 93825067691187, 96,
140737488344480}
            }
          }}
        save_jump = {{
            __jmpbuf = {140737488344160, 93824994294759,
93825063578261, 10092931733, 0, 37152,
              140737488344352, 140737254736672},
            __mask_was_saved = 1502997141,
            __saved_mask = {
              __val = {10034, 0, 37152, 93825002700224, 37152,
140737488344160, 57276693952,
                93825063578261, 140737488344176, 93824994274948,
93825063578261, 140737488344208,
                93824994275044, 93824994265917, 93825063578261, 140737488344272}
            }
          }}
        tem = XIL(0x30)
        save = XIL(0x555557535ef0)
        previous_echo_area_message = XIL(0)
        also_record = XIL(0)
        reread = false
        recorded = false
        polling_stopped_here = false
        orig_kboard = 0x555558e79b00
        jmpcount = {
          bytes = 0
        }
#9  0x00005555556a727f in read_key_sequence (keybuf=0x7fffffffd8f0,
prompt=XIL(0),
    dont_downcase_last=false, can_return_switch_frame=true,
fix_current_buffer=true,
    prevent_redisplay=false, disable_text_conversion_p=false) at
keyboard.c:10728
        interrupted_kboard = 0x555558e79b00
        interrupted_frame = 0x5555593233b0
        key = XIL(0x555559d4cbd3)
        used_mouse_menu = false
        echo_local_start = 0
        last_real_key_start = 0
        keys_local_start = 0
        new_binding = XIL(0)
        count = {
          bytes = 96
        }
        t = 0
        echo_start = 0
        keys_start = 0
        current_binding = XIL(0x555559d4aca3)
        first_unbound = 31
        mock_input = 0
        used_mouse_menu_history = {false <repeats 30 times>}
        fkey = {
          parent = XIL(0x5555594a6123),
          map = XIL(0x5555594a6123),
          start = 0,
          end = 0
        }
        keytran = {
          parent = XIL(0x7ffff210d433),
          map = XIL(0x7ffff210d433),
--Type <RET> for more, q to quit, c to continue without paging--
          start = 0,
          end = 0
        }
        indec = {
          parent = XIL(0x5555594a6113),
          map = XIL(0x5555594a6113),
          start = 0,
          end = 0
        }
        shift_translated = false
        delayed_switch_frame = XIL(0)
        original_uppercase = XIL(0)
        original_uppercase_position = -1
        starting_buffer = 0x55555995ea90
        fake_prefixed_keys = XIL(0x555559d4b013)
        first_event = XIL(0)
        second_event = XIL(0)
#10 0x0000555555691967 in command_loop_1 () at keyboard.c:1429
        cmd = XIL(0x2aaa9bd8fa68)
        keybuf = {XIL(0xafe0), XIL(0x555559d4cbd3), make_fixnum(60),
make_fixnum(53),
          make_fixnum(126), make_fixnum(49), make_fixnum(126), XIL(0),
XIL(0), XIL(0x555555f55a00),
          XIL(0x555555744b3d), XIL(0x30), XIL(0x7fffffffd9e0),
XIL(0x55555574bbe7),
          XIL(0x555560452f85), XIL(0x200000000), XIL(0x30),
XIL(0xed60), XIL(0x7ffff18ef975),
          XIL(0x7ffff21346f0), make_fixnum(23456248603222),
XIL(0x7ffff18ef975), XIL(0x3),
          XIL(0xed60), XIL(0x555555f55a00), XIL(0xed60),
XIL(0x7fffffffd9e0), XIL(0x555555f55a00),
          XIL(0x5555557682e7), XIL(0x30)}
        i = 2
        last_pt = 2508
        prev_modiff = 18813
        prev_buffer = 0x55555995ea90
#11 0x000055555576d165 in internal_condition_case (bfun=0x555555691538
<command_loop_1>,
    handlers=XIL(0x90), hfun=0x5555556909e3 <cmd_error>) at eval.c:1613
        val = make_fixnum(23456248378977)
        c = 0x555556048380
#12 0x0000555555691116 in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1168
        val = make_fixnum(0)
#13 0x000055555576c592 in internal_catch (tag=XIL(0xfc90),
func=0x5555556910ec <command_loop_2>,
    arg=XIL(0x90)) at eval.c:1292
        val = XIL(0x7fffffffdc00)
        c = 0x5555560c0d90
#14 0x00005555556910a8 in command_loop () at keyboard.c:1146
No locals.
#15 0x0000555555690485 in recursive_edit_1 () at keyboard.c:754
        count = {
          bytes = 32
        }
        val = XIL(0x5555557729bc)
#16 0x00005555556906b1 in Frecursive_edit () at keyboard.c:837
        count = {
          bytes = 0
        }
        buffer = XIL(0)
#17 0x000055555568c118 in main (argc=2, argv=0x7fffffffdf18) at emacs.c:2625
        stack_bottom_variable = 0x0
        old_argc = 2
        dump_file = 0x0
        no_loadup = false
        junk = 0x0
        dname_arg = 0x0
        ch_to_dir = 0x0
        original_pwd = 0x0
        dump_mode = 0x0
        skip_args = 1
--Type <RET> for more, q to quit, c to continue without paging--
        temacs = 0x0
        attempt_load_pdump = true
        only_version = false
        rlim = {
          rlim_cur = 10022912,
          rlim_max = 18446744073709551615
        }
        lc_all = 0x0
        sockfd = -1
        module_assertions = false
(gdb)

(gdb) p delayed_size_change
$1 = false

On Mon, 3 Jun 2024 at 17:40, Eli Zaretskii <[email-masked]> wrote:
>
> > From: Daniel Clemente <[email-masked]>
> > Date: Mon, 3 Jun 2024 16:55:25 +0000
> > Cc: [email-masked]
> >
> > > > But sometimes I can't reproduce it at all with this method!
> > > > And never could I in emacs -Q
> > >
> > > So maybe you could bisect your init files and find the
> > > customization(s) which make the reproduction possible?  Because I
> > > cannot reproduce any of this here, no matter what I try.
> >
> > I tried but it took too long to evaluate each version, because I don't
> > have a formula to reproduce this. Sometimes I could crash it in
> > seconds, sometimes I couldn't in minutes.
> > I'll try to reproduce it in a faster way.
>
> Please update from Git before trying anything else wrt this bug.  I
> installed a simple baind-aid that is intended to avoid problems with
> frame dimensions while we have an unhandled SIGWINCH.