Subject: 31.0.50; Emacs sometimes crashes if several frames are present
From: Markus Triska <[email-masked]>
To: [email-masked]
Date: Sun, 23 Mar 2025 09:45:17 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

To reproduce this issue, please download several_frames_tty.el from:

    https://www.metalevel.at/ei/several_frames_tty.el

Then start Emacs with:

    $ emacs -Q -nw --load several_frames_tty.el

Leave it running for a bit, and then press:

    C-g C-x C-c

The expectation is that Emacs exits, and it works as expected in many
cases. However, in some cases, I get:

    /lib/x86_64-linux-gnu/libc.so.6(+0x28150)[0x7deeafe28150]
    /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0x89)[0x7deeafe28209]
    ./emacs(+0x3f5c5)[0x59a98895d5c5]
    Segmentation fault (core dumped)

I attach the backtrace below.

The example is related to #77046 in that it also causes a
crash. However, this time, several different frames are involved, and
the backtrace is different, so I file this as a seperate issue. Please
do merge the issues if you consider them equivalent.

Thank you and all the best,
Markus

#0  0x000055555559ce5f in check_matrix_pointers (window_matrix=0x0, frame_matrix=0x0) at dispnew.c:3145
#1  0x000055555559cdd7 in check_window_matrix_pointers (w=0x5555560beba0) at dispnew.c:3123
#2  0x000055555559f8f9 in combine_updates_for_frame (f=0x555555b15660, inhibit_scrolling=false) at dispnew.c:4074
#3  0x000055555559f9cc in combine_updates (roots=XIL(0x7ffff72df523)) at dispnew.c:4097
#4  0x00005555556023a9 in redisplay_internal () at xdisp.c:17748
#5  0x00005555555ffa42 in redisplay () at xdisp.c:16802
#6  0x0000555555766abf in read_char (commandflag=1, map=XIL(0x7ffff7341e83), prev_event=XIL(0), used_mouse_menu=0x7fffffffd769, end_time=0x0) at keyboard.c:2672
#7  0x000055555577bc92 in read_key_sequence (keybuf=0x7fffffffd990, 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:10848
#8  0x0000555555762a9b in command_loop_1 () at keyboard.c:1424
#9  0x000055555584add0 in internal_condition_case (bfun=0x55555576264d <command_loop_1>, handlers=XIL(0x90), hfun=0x555555761a40 <cmd_error>) at eval.c:1620
#10 0x00005555557621f0 in command_loop_2 (handlers=XIL(0x90)) at keyboard.c:1163
#11 0x000055555584a1a1 in internal_catch (tag=XIL(0x11df0), func=0x5555557621c2 <command_loop_2>, arg=XIL(0x90)) at eval.c:1300
#12 0x000055555576217e in command_loop () at keyboard.c:1141
#13 0x00005555557614c2 in recursive_edit_1 () at keyboard.c:749
#14 0x00005555557616f6 in Frecursive_edit () at keyboard.c:832
#15 0x000055555575cc04 in main (argc=5, argv=0x7fffffffde58) at emacs.c:2560

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

In GNU Emacs 31.0.50 (build 4, x86_64-pc-linux-gnu, X toolkit, Xaw
 scroll bars) of 2025-03-23 built on laptop
Repository revision: ab25b4fca9a20ccc03a90ec9c2281a2f88872d93
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12302000
System Description: Ubuntu 23.10

Configured using:
 'configure --with-x-toolkit=lucid --with-xpm=ifavailable
 --with-gif=ifavailable --with-tiff=ifavailable
 --with-gnutls=ifavailable --enable-checking=yes,glyphs
 --enable-check-lisp-object-type 'CFLAGS=-O0 -g3''

Configured features:
FREETYPE GMP JPEG LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP
SOUND THREADS TOOLKIT_SCROLL_BARS X11 XDBE XFT XIM XPM LUCID ZLIB