Subject: bug#8750: 24.0.50; Crash in daemon mode when display goes away

From: Nix <[email-masked]>
Date: Sat, 28 May 2011 11:40:48 +0100

I suspend my desktop box every night, to save power. My Emacs runs on a
remote system in --daemon mode, and is never shut down. $DISPLAY on that
system points directly to the desktop box: this is sometimes suspended,
so the TCP/IP connection cannot be assumed to stay up. (Nonetheless, if
it goes away, if it is re-established, the X session will be exactly as
it was.)

When this happens, Emacs's X error handler kicks in and kills it:

#0  0x00007f3f639ea357 in kill () from /lib/libc.so.6
#1  0x00000000004fc26f in fatal_error_signal (sig=<value optimized out>) at emacs.c:342
#2  <signal handler called>
#3  0x00007f3f639ea357 in kill () from /lib/libc.so.6
#4  0x00000000004fba85 in abort () at emacs.c:371
#5  0x0000000000446595 in redisplay_internal () at xdisp.c:11511
#6  0x0000000000446ab3 in redisplay_preserve_echo_area (from_where=<value optimized out>) at xdisp.c:12163
#7  0x00000000005b2707 in Fdelete_process (process=71306213) at process.c:779
#8  0x00000000005b5b7d in kill_buffer_processes (buffer=11868546) at process.c:7003
#9  0x00000000004fbffa in shut_down_emacs (sig=0, no_x=<value optimized out>, stuff=11868546) at emacs.c:2040
#10 0x00000000004b9489 in x_connection_closed (dpy=<value optimized out>, error_message=<value optimized out>) at xterm.c:7758
#11 0x00000000004b96b5 in x_io_error_quitter (display=0xde1ff0) at xterm.c:7866
#12 0x00007f3f6619346e in _XIOError (dpy=0xde1ff0) at XlibInt.c:1602
#13 0x00007f3f6619190e in _XReply (dpy=0xde1ff0, rep=0x7ffff7e82500, extra=<value optimized out>, discard=<value optimized out>) at xcb_io.c:632
#14 0x00007f3f661867a3 in XQueryColors (dpy=0xde1ff0, cmap=2, defs=0x7ffff7e825d0, ncolors=2) at QuColors.c:55
#15 0x00000000005d380c in xftfont_get_colors (f=0xfcc6f0, face=0xf0050d0, gc=<value optimized out>, xftface_info=0x0, fg=0xd495c20, bg=0xd495c30) at xftfont.c:121
#16 0x00000000005d41e9 in xftfont_prepare_face (f=0xfcc6f0, face=0xf0050d0) at xftfont.c:533
#17 0x00000000004b1112 in prepare_face_for_display (f=0xfcc6f0, face=0xf0050d0) at xfaces.c:4165
#18 0x000000000042e14c in get_glyph_face_and_encoding (s=0x7ffff7e82960, face_id=12, start=<value optimized out>, end=<value optimized out>, overlaps=<value optimized out>) at xdisp.c:20536
#19 fill_glyph_string (s=0x7ffff7e82960, face_id=12, start=<value optimized out>, end=<value optimized out>, overlaps=<value optimized out>) at xdisp.c:20744
#20 0x000000000044d70f in draw_glyphs (w=0xfcc980, x=103, row=<value optimized out>, area=TEXT_AREA, start=0, end=259, hl=DRAW_NORMAL_TEXT, overlaps=0) at xdisp.c:21359
#21 0x000000000045343d in x_write_glyphs (start=<value optimized out>, len=259) at xdisp.c:23101
#22 0x000000000041706a in update_text_area (w=0xfcc980, vpos=100, mouse_face_overwritten_p=0x7ffff7e8310c) at dispnew.c:3808
#23 update_window_line (w=0xfcc980, vpos=100, mouse_face_overwritten_p=0x7ffff7e8310c) at dispnew.c:4049
#24 0x0000000000418b01 in update_window (w=0xfcc980, force_p=0) at dispnew.c:3611
#25 0x0000000000419c03 in update_window_tree (w=0xfcc980, force_p=0) at dispnew.c:3369
#26 0x000000000041ce56 in update_frame (f=0xfcc6f0, force_p=0, inhibit_hairy_id_p=0) at dispnew.c:3296
#27 0x0000000000445a01 in redisplay_internal () at xdisp.c:11949
#28 0x0000000000446ab3 in redisplay_preserve_echo_area (from_where=<value optimized out>) at xdisp.c:12163
#29 0x0000000000507f90 in detect_input_pending_run_timers (do_display=1) at keyboard.c:10442
#30 0x00000000005b0b0e in wait_reading_process_output (time_limit=0, microsecs=0, read_kbd=<value optimized out>, do_display=1, wait_for_cell=11868546, wait_proc=0x0, just_wait_proc=0) at process.c:4618
#31 0x0000000000508f8e in kbd_buffer_get_event (commandflag=1, nmaps=9, maps=0x7ffff7e853a0, prev_event=11868546, used_mouse_menu=0x7ffff7e855bc, end_time=0x0) at keyboard.c:3840
#32 read_char (commandflag=1, nmaps=9, maps=0x7ffff7e853a0, prev_event=11868546, used_mouse_menu=0x7ffff7e855bc, end_time=0x0) at keyboard.c:2786
#33 0x000000000050aefe in read_key_sequence (keybuf=0x7ffff7e85620, prompt=11868546, dont_downcase_last=0, can_return_switch_frame=1, fix_current_buffer=1, bufsize=30) at keyboard.c:9272
#34 0x000000000050cafb in command_loop_1 () at keyboard.c:1445
#35 0x00000000005709ae in internal_condition_case (bfun=0x50c920 <command_loop_1>, handlers=11920930, hfun=0x5020b0 <cmd_error>) at eval.c:1507
#36 0x0000000000500d6e in command_loop_2 (ignore=<value optimized out>) at keyboard.c:1156
#37 0x0000000000570888 in internal_catch (tag=Cannot access memory at address 0x6dfc
) at eval.c:1261
#38 0x0000000000501b6a in command_loop () at keyboard.c:1135
#39 recursive_edit_1 () at keyboard.c:756
#40 0x0000000000501ea6 in Frecursive_edit () at keyboard.c:820
#41 0x00000000004fcd95 in main (argc=<value optimized out>, argv=0x7ffff7e85e88) at emacs.c:1686

This seems an excessive reaction to the X connection going away,
particularly in --daemon mode, where it might have a dozen connections
to different X displays. At suspension time I have closed all the frames
anyway, so what's it doing in read_key_sequence()? What frame is it
updating? It shouldn't have any left!

(If this is impossible, can anyone suggest a way to keep Emacs running
while the X server is down? I've tried xpra, but its keyboard handling
is too broken :( )

In GNU Emacs 24.0.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.18.8)
 of 2011-05-26 on spindle
Windowing system distributor `The X.Org Foundation', version 11.0.10903902
configured using `configure  '--without-pop' '--without-kerberos' '--without-hesiod' '--without-mmdf' '--with-x-toolkit=gtk' 'NO_FAST_MATH=t''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: C
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_GB.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Group

Minor modes in effect:
  gnus-topic-mode: t
  gnus-undo-mode: t
  iswitchb-mode: t
  show-paren-mode: t
  global-cwarn-mode: t
  global-semanticdb-minor-mode: t
  global-semantic-idle-completions-mode: t
  global-semantic-idle-scheduler-mode: t
  compile-bookmarks-mode: t
  semantic-mode: t
  type-break-mode-line-message-mode: t
  icomplete-mode: t
  recentf-mode: t
  mv-shell-mode: t
  which-function-mode: t
  desktop-save-mode: t
  display-time-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t

Recent input:
<backspace> <escape> <backspace> <escape> <backspace> 
<escape> <backspace> i n i <tab> m <tab> e <tab> <return> 
C-s C-s C-s C-s C-s C-s C-a C-s n n i m a p C-s C-s 
C-a C-x k <return> C-x C-f <up> <backspace> <escape> 
<backspace> <escape> <escape> <backspace> <escape> 
<escape> <backspace> <escape> <backspace> <escape> 
<backspace> <escape> <backspace> d o <tab> g o <tab> 
<backspace> n u <tab> m a i <tab> <return> C-s C-s 
C-s C-a C-s n n i m a p C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s C-s 
C-s C-s C-s C-s C-s C-s C-s C-s C-s C-a C-x k <return> 
C-x C-f <up> <up> <down> <S-left> <S-left> C-k a r 
<tab> <return> C-s C-s C-s <up> <left> <down> <up> 
<right> C-e <return> <tab> ( n o t SPC ( n u l l SPC 
<S-left> <S-left> a n d SPC ( C-e g n u s - n e w s 
g r o u p - n a m e ) ) <down> <tab> ) <down> <down> 
<down> <up> <escape> C-b <right> <left> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <down> 
<down> <down> <down> <down> <down> <down> <down> <up> 
<up> <up> <up> <up> <end> C-x C-\ C-g C-x C-e <right> 
C-x C-s <escape> x b y t e - r e <tab> f <tab> <return> 
<return> C-x b <return> M-x r e p o r t - e m a <tab> 
<return> C-g <escape> : <up> <left> C-e <left> <backspace> 
n i l <return> M-x <up> <return>

Recent messages:
Auto-saving...
Mark saved where search started [4 times]
Quit
(((or (string= "alt.sysadmin.recovery" gnus-newsgroup-name) (string= "alt.dev.null" gnus-newsgroup-name)) ("Approved" "foo")) ((message-news-p) (address "[email-masked]") (Reply-To "Nix <[email-masked]>")) ((or (nix-at-work-p) (and ... ...)) (name "Nick Alcock") (address "[email-masked]")))
Saving file /home/nix/lisp/emacs/personal/dot-gnus-articles.el...
Wrote /home/nix/lisp/emacs/personal/dot-gnus-articles.el
Showing all blocks ... done
Compiling /home/nix/lisp/emacs/personal/dot-gnus-articles.el...done
Wrote /home/nix/lisp/emacs/personal/dot-gnus-articles.elc
Quit
nil

Load-path shadows:
/home/nix/lisp/defaults hides /usr/share/emacs/site-lisp/defaults
/home/nix/lisp/emacs/site-wide/site-start hides /usr/share/emacs/site-lisp/site-start
/home/nix/lisp/emacs/site-wide/default hides /usr/share/emacs/site-lisp/default
/home/nix/lisp/emacs/site-wide/scroll-in-place hides /usr/share/emacs/site-lisp/scroll-in-place
/usr/share/emacs/site-lisp/emms/tq hides /usr/share/emacs/24.0.50/lisp/emacs-lisp/tq

Features:
(shadow debug gnus-cite emacsbug multi-isearch gnus-topic url-cache
url-http url-gw url-auth url-handlers nndraft nnrss xml gnus-agent
gnus-srvr gnus-score score-mode nnvirtual gnus-msg utf-7 nnimap
parse-time utf7 nnmh nnml nnfolder gnus-cache bbdb-gnus bbdb-snarf rot13
epa-file epa derived epg netrc gnus-demon nntp dot-gnus-mail
dot-gnus-splits mm-url smtpmail gnus-art mm-uu mml2015 epg-config
mm-view mml-smime smime dig dot-gnus-articles dot-gnus-sa background
nnir gnus-sum nnoo gnus-group gnus-undo nnmail mail-source dot-gnus-bbdb
dot-gnus-colourization tc mail-extr gnus-start gnus-spec gnus-int
gnus-range gnus-win gnus gnus-ems nnheader jka-compr vc-git checkdoc
thingatpt eldoc generic site-default dot-emacs dot-emacs-emacs iswitchb
xemacs-compat add-log misc init-music network-stream starttls tls
emms-volume emms-volume-amixer emms-history emms-bookmarks
emms-metaplaylist-mode emms-browser sort emms-playlist-sort
emms-last-played emms-playing-time emms-stream-info emms-streams
emms-mode-line emms-cache emms-info later-do emms-playlist-limit
emms-playlist-mode emms-player-mpd tq emms-player-simple
emms-source-playlist emms-source-file dired emms emms-compat
init-message-modes bbdb-expire bbdb-hooks bbdb-com silly-mail boxquote
rect message sendmail rfc822 mml mml-sec mm-decode mm-bodies mm-encode
mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev mail-utils
gmm-utils mailheader init-time-tracking timeclock-visualize sgml-mode
url url-proxy url-privacy url-expand url-methods url-history url-cookie
url-util url-parse url-vars mailcap auto-edit-substitute init-prog-modes
init-prog-modes-emacs filecache paren cwarn cc-mode cc-fonts cc-menus
semantic/db-mode semantic/db eieio-base semantic/idle semantic/format
ezimage semantic/tag-ls semantic/ctxt htmlfontify cus-edit cus-start
cus-load compile-bookmarks font-latex latex easy-mmode edmacro kmacro
tex-style tex semantic/util-modes semantic/util semantic semantic/tag
semantic/lex semantic/fw mode-local cedet cc-cmds cc-styles cc-align
cc-engine cc-vars cc-defs miniedit type-break icomplete site-start-load
gawd-keys help-mode view gawd-keys-emacs gawd-mode-frobs
gawd-mode-frobs-emacs windmove recentf tree-widget wid-edit mv-shell
printing ps-print ps-def lpr uptimes pp bbdb timezone browse-kill-ring+
browse-kill-ring tempbuf timeclock igrep grep compile term disp-table
ehelp electric comint tramp tramp-compat auth-source eieio assoc
gnus-util time-date mm-util mail-prsvr password-cache format-spec
tramp-loaddefs regexp-opt hideshow filladapt gawd-faces gawd-faces-emacs
nix-dark-theme gawd-misc gawd-misc-emacs which-func imenu winner
gawd-lists bbdb-autoloads desktop generic-x uniquify byte-opt warnings
bytecomp byte-compile cconv macroexp time advice help-fns advice-preload
scroll-in-place site-start-emacs site-autoloads auctex-autoloads
tex-site info c-eldoc-autoloads compilation-recenter-end-autoloads
compile-bookmarks-autoloads dictionary-autoloads diff-git-autoloads
elk-test-autoloads fringe-helper-autoloads full-ack-autoloads
htmlize-autoloads jump-autoloads inflections-autoloads findr-autoloads
lua-mode-autoloads mv-shell-autoloads package tabulated-list emms-auto
w3m-load apropos-toc cl ring filesets easymenu flash-paren saveplace
redo+ tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd
tool-bar dnd fontset image fringe lisp-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 loaddefs button faces
cus-face files text-properties overlay sha1 md5 base64 format env
code-pages mule custom widget hashtable-print-readable backquote
make-network-process dbusbind dynamic-setting system-font-setting
font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)

-- 
NULL && (void)