Subject: bug#56528: 29.0.50; Emacs lucid segfaults when X dies

From: [email-masked]
Date: Wed, 13 Jul 2022 10:02:18 +0530

When X dies, Emacs lucid segfaults (backtrace attached as
emacs.backtrace).  I confirmed that xrdb read 'emacs.synchronous: true'
by running xrdb -q.

After starting Emacs in the gdb session, I switched over to the right X
display and ran,

        1. M-x server-start RET
        2. Said emacsclient -c in a terminal
        3. In the spawned emacsclient, I ran proced to find out the pid for
           the Xorg server and killed it by saying M-! kill <pid> RET
        4. Switched over to the gdb session, and produced the backtrace.

[ It doesn't seem to always segfault tho, but the Emacs process certainly
  always dies when X goes down.  I also produced the backtrace for
  not-segfault case and I'm attaching it as emacs.backtrace.nosegfault.  ]

P.S. This is my first time running gdb so apologies for any mistakes.

In GNU Emacs 29.0.50 (build 6, x86_64-pc-linux-gnu, X toolkit, Xaw scroll bars)
 of 2022-07-13 built on astatine
Repository revision: 6be201cf51e0b1c69e713dec318cef18eef4c617
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101003
System Description: Debian GNU/Linux bookworm/sid

Configured using:
 'configure --enable-checking=yes,glyphs --enable-check-lisp-object-type
 --without-cairo --with-x-toolkit=lucid --without-xaw3d 'CFLAGS=-O0
 -g3''

Configured features:
ACL DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG JSON
LIBOTF LIBSELINUX LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG RSVG
SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP X11 XDBE XFT
XIM XINPUT2 XPM LUCID ZLIB

Important settings:
  value of $LC_MONETARY: ta_IN.UTF-8
  value of $LC_NUMERIC: ta_IN.UTF-8
  value of $LANG: en_GB.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Nroff

Minor modes in effect:
  tooltip-mode: t
  global-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
  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 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 time-date subr-x mm-decode
mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader
sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
nroff-mode vc-git diff-mode vc vc-dispatcher bug-reference cc-mode
cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars
cc-defs files-x gdb-mi bindat byte-opt gv bytecomp byte-compile cconv
cl-seq cl-loaddefs cl-lib gud easy-mmode comint ansi-color ring rmc
iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
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 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
dynamic-setting system-font-setting font-render-setting x-toolkit
xinput2 x multi-tty make-network-process emacs)

Memory information:
((conses 16 96063 12338)
 (symbols 48 9560 0)
 (strings 32 30150 2121)
 (string-bytes 1 1302518)
 (vectors 16 23326)
 (vector-slots 8 931315 173264)
 (floats 8 128 43)
 (intervals 56 2696 0)
 (buffers 992 18))