Subject: bug#78980: 31.0.50; C-z crashes emacsclient -nw

From: Eli Zaretskii <[email-masked]>
Date: Wed, 09 Jul 2025 16:31:25 +0300

This bug report will be sent to the Bug-GNU-Emacs mailing list
and the GNU bug tracker at debbugs.gnu.org.  Please check that
the From: line contains a valid email address.  After a delay of up
to one day, you should receive an acknowledgment at that address.

Please write in English if possible, as the Emacs maintainers
usually do not have translators for other languages.

Please describe exactly what actions triggered the bug, and
the precise symptoms of the bug.  If you can, give a recipe
starting from 'emacs -Q':

To reproduce:

 $ emacs -Q -nw
 M-x server-start RET

Then from another terminal:

 $ emacsclient -nw
 C-z

This crashes Emacs.  Here's the backtrace:

  Thread 1 "emacs" hit Breakpoint 1, terminate_due_to_signal (sig=sig@entry=6, \
backtrace_limit=backtrace_limit@entry=2147483647) at emacs.c:442
  442     {
  (gdb) bt
  #0  terminate_due_to_signal
      (sig=sig@entry=6, backtrace_limit=backtrace_limit@entry=2147483647)
      at emacs.c:442
  #1  0x0000561edf8b3962 in die
      (msg=msg@entry=0x561edfbb609a "CONSP (a)", file=file@entry=0x561edfbb6020\
 "lisp.h", line=line@entry=1477) at alloc.c:7355
  #2  0x0000561edf89b9cf in XCONS (a=<optimized out>)
      at /home/eliz/git/emacs/trunk/src/lisp.h:1477
  #3  0x0000561edf89c48c in XCONS (a=<optimized out>) at dispnew.c:3364
  #4  XCAR (c=<optimized out>) at /home/eliz/git/emacs/trunk/src/lisp.h:1504
  #5  frames_in_reverse_z_order (f=<optimized out>, visible_only=true)
      at dispnew.c:3458
  #6  0x0000561edf8d47c3 in is_tty_root_frame_with_visible_child
      (f=<optimized out>) at dispnew.c:3518
  #7  0x0000561edf92e0a1 in redisplay_internal () at xdisp.c:17390
  #8  0x0000561edfa46b6a in read_char
      (commandflag=1, map=XIL(0x7f7257b0e3a3), prev_event=XIL(0), used_mouse_me\
nu=0x7fff32d5291b, end_time=0x0) at keyboard.c:2672
  #9  0x0000561edfa48bdc in read_key_sequence
      (keybuf=0x7fff32d52a70, prompt=XIL(0), dont_downcase_last=<optimized out>\
, can_return_switch_frame=true, fix_current_buffer=true, prevent_redisplay=<opt\
imized out>, disable_text_conversion_p=false) at keyboard.c:10882
  #10 0x0000561edfa4a9a1 in command_loop_1 () at keyboard.c:1424
  #11 0x0000561edfad8247 in internal_condition_case
      (bfun=bfun@entry=0x561edfa4a730 <command_loop_1>, handlers=handlers@entry\
=XIL(0x90), hfun=hfun@entry=0x561edfa3ccf0 <cmd_error>) at eval.c:1684
  #12 0x0000561edfa3255e in command_loop_2 (handlers=handlers@entry=XIL(0x90))
      at keyboard.c:1163
  #13 0x0000561edfad80c9 in internal_catch
      (tag=tag@entry=XIL(0x125d0), func=func@entry=0x561edfa32530 <command_loop\
_2>, arg=arg@entry=XIL(0x90)) at eval.c:1364
  #14 0x0000561edfa324f9 in command_loop () at keyboard.c:1141
  #15 0x0000561edfa3c7a5 in recursive_edit_1 () at keyboard.c:749
  #16 0x0000561edfa3cb58 in Frecursive_edit () at keyboard.c:832
  #17 0x0000561edf8c80d2 in main (argc=<optimized out>, argv=<optimized out>)
      at emacs.c:2582

I guess 'frames' is nil here, so we hit the assertion violation?

  Lisp_Object
  frames_in_reverse_z_order (struct frame *f, bool visible_only)
  {
    struct frame *root = root_frame (f);
    Lisp_Object frames = frames_with_root (root, visible_only);
    frames = CALLN (Fsort, frames, QClessp, Qframe__z_order_lessp);
    eassert (FRAMEP (XCAR (frames)));
    eassert (XFRAME (XCAR (frames)) == root);
    return frames;
  }

If Emacs crashed, and you have the Emacs process in the gdb debugger,
please include the output from the following gdb commands:
    'bt full' and 'xbacktrace'.
For information about debugging Emacs, please read the file
/home/eliz/git/emacs/trunk/etc/DEBUG.

In GNU Emacs 31.0.50 (build 276, x86_64-pc-linux-gnu, GTK+ Version
 3.24.33, cairo version 1.16.0) of 2025-07-09 built on
 maintain0p.gnu.org
Repository revision: 8497cfeaeac832ff98730388567526a42b321d85
Repository branch: master
System Description: Trisquel GNU/Linux Aramo (11.0.1)

Configured using:
 'configure --with-gif=ifavailable --with-tiff=ifavailable
 --with-jpeg=ifavailable --with-xpm=ifavailable
 --without-native-compilation --enable-checking=yes,glyphs 'CFLAGS=-O2
 -g3''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2 M17N_FLT MODULES NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS WEBP X11 XDBE XIM XINERAMA XINPUT2 XPM XRANDR GTK3
ZLIB

Important settings:
  value of $LC_ALL: en_US.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  minibuffer-regexp-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug lisp-mnt message mailcap yank-media puny
dired dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg
rfc6068 epg-config gnus-util text-property-search mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail
rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils time-date
subr-x cl-loaddefs cl-lib term/xterm xterm byte-opt gv bytecomp
byte-compile rmc iso-transl tooltip cconv eldoc paren electric uniquify
ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/x-win x-win
term/common-win x-dnd touch-screen tool-bar dnd fontset image regexp-opt
fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode
register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select
scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors
frame minibuffer nadvice seq simple cl-generic indonesian philippine
cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech
european ethiopic indian cyrillic chinese composite emoji-zwj charscript
charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure
cl-preloaded button loaddefs theme-loaddefs faces cus-face macroexp
files window text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget keymap hashtable-print-readable backquote
threads dbusbind inotify lcms2 dynamic-setting system-font-setting
font-render-setting cairo gtk x-toolkit xinput2 x multi-tty move-toolbar
make-network-process tty-child-frames emacs)

Memory information:
((conses 16 48462 10465) (symbols 48 6200 0) (strings 32 14276 1689)
 (string-bytes 1 349218) (vectors 16 7538) (vector-slots 8 63531 7250)
 (floats 8 25 355) (intervals 56 245 8) (buffers 984 10))