Subject: bug#17891: 24.3.92; crash with x-popup-dialog in daemon mode with enable-checking

From: Ken Raeburn <[email-masked]>
Date: Tue, 1 Jul 2014 03:28:04 -0400

Configure with --with-x-toolkit=lucid --enable-checking.

Create a .emacs file with:
  (menu-bar-mode -1)

Run under X11:
  emacsclient -c -n -a ""

Evaluate (e.g., in ielm):
  (x-popup-dialog t '("hello"))

Emacs crashes:
#0  0x00007f4c889aaefb in raise () from /lib/x86_64-linux-gnu/libpthread.so.0
#1  0x0000000000517898 in terminate_due_to_signal (sig=sig@entry=6, 
    backtrace_limit=backtrace_limit@entry=2147483647) at emacs.c:378
#2  0x000000000057d644 in die (msg=msg@entry=0x644af8 "FRAMEP (globals.f_Vmenu_updating_frame)", 
    file=file@entry=0x644c03 "menu.c", line=line@entry=469) at alloc.c:6833
#3  0x000000000047c543 in encode_menu_string (str=<optimized out>) at menu.c:469
#4  encode_menu_string (str=<optimized out>) at menu.c:465
#5  0x000000000047c7e5 in list_of_panes (menu=<optimized out>) at menu.c:515
#6  0x0000000000480b42 in xw_popup_dialog (f=0x129eca8, header=13116274, contents=20629990)
    at xmenu.c:2051
#7  0x000000000059dbda in eval_sub (form=form@entry=20632694) at eval.c:2191
#8  0x00000000005a0542 in Feval (form=20632694, lexical=<optimized out>) at eval.c:2003
[...]

In encode_menu_string we do:
469	  if (FRAME_TERMCAP_P (XFRAME (Vmenu_updating_frame)))
470	    return str;

but Vmenu_updating_frame is nil.

With enable-checking, Emacs will crash; without it, it seems to quietly look at some random bit of memory and (usually?) do something that doesn't immediately cause a crash, so far.

If daemon mode isn't used to start Emacs, then menu-updating-frame will be non-nil.
If menu bar mode is left enabled (by default) then again menu-updating-frame will be non-nil.

I've run into this when clicking on a button in customize buffers caused a dialog window to be popped up.

In GNU Emacs 24.3.92.2 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2014-07-01 on d42
Windowing system distributor `The X.Org Foundation', version 11.0.11406000
System Description:	Debian GNU/Linux 7.5 (wheezy)

Configured using:
 `configure --with-x-toolkit=lucid --prefix=/home/ken/dev/e2/I
 --enable-checking'

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

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent input:
<escape> x r e p o r t - e m <tab> <return>

Recent messages:
Starting Emacs daemon.
When done with this frame, type C-x 5 0

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils server time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar
dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
dbusbind gfilenotify dynamic-setting system-font-setting
font-render-setting x-toolkit x multi-tty emacs)

Memory information:
((conses 16 70866 5767)
 (symbols 48 17526 0)
 (miscs 40 43 138)
 (strings 32 9288 5530)
 (string-bytes 1 262927)
 (vectors 16 9185)
 (vector-slots 8 379419 13765)
 (floats 8 69 62)
 (intervals 56 175 0)
 (buffers 960 12)
 (heap 1024 33237 612))