Subject: bug#20247: 24.4; Emacs hangs at startup in desktop mode

From: "Richard Munitz (BLOOMBERG/ 731 LEX)" <[email-masked]>
Date: Thu, 2 Apr 2015 15:22:33 -0000

--text follows this line--
I have emacs configured in my .emacs to save desktop settings:
(desktop-save-mode 1)
(setq desktop-auto-save-timeout 60)

I work on Solaris and access via xterm.  I also use tmux on top of that.   The machine is restarted periodically (always on the weekends for example) and I am forced to log back in.  After I do this, I often find that when I start emacs (just run "emacs"), it hangs and I have no choice but to kill it.  I have tried exiting emacs before leaving before work for the weekend and had this hang occur when I returned on Monday.

I have done some investigation and have determined that the hang is caused by the presence of something like the following string in my ~/.emacs.d/.emacs.desktop file: (display . "sundev28:37.0")
That display value winds up being the value that was in effect during my prior login.  However my new login/xterm is assigned a different display value.  I have determined that if I edit the desktop file (emacs .emacs.desktop file --no-desktop) and change that display string to the current $DISPLAY value, emacs now starts without hanging.

I find that the hang is not consistent.  For example, if I simply edit the display value to some bogus value (e.g. change the 37 above to 137), emacs at least comes up without hanging.  It doesn't restore my desktop layout (frame position, size, splits), and it instead displays the warning: 
Error (frameset): Display sundev28:137.0 can't be opened
Warning (frameset): Attempt to delete the sole visible or iconified frame

Some more information.  This problem could be related to tmux.  The last time the hang occurred I noticed that my environment settings had different values for XTERM and DISPLAY.  Currently they look like the below, but on that day they were different.  Unfortunately, I don't remember which was which.  But the .emacs.desktop file had one of the two values and it hung.  When I edited the file and changed it to the other of the two values, it started flawlessly.
XTERM=/usr/bin/X11/xterm -ls -sb -sl 4000 -display sundev28:37.0
DISPLAY=sundev28:37.0

Of course I don't understand the internals, but I don't understand why emacs starts up and tries to use a saved "display" value at all?  Why doesn't it just always use the display value defined in the current shell in which I am invoking emacs?  Perhaps this is sometimes desirable, but is there a setting I can use to make emacs ignore this value saved in the desktop file and always use the value from the current environment?

In GNU Emacs 24.4.1 (sparc-sun-solaris2.10, GTK+ Version 3.8.9)
of 2015-03-25 on njsbldo2
Windowing system distributor `Hummingbird - Open Text', version 11.0.13830
Configured using:
`configure --prefix=/opt/bb --libdir=/opt/bb/lib64
-x-includes=/opt/bb/include -x-libraries=/opt/bb/lib64
--without-selinux --with-png=no --with-gif=no --without-gsettings
CFLAGS=-m64 CPPFLAGS=-I/opt/bb/include 'LDFLAGS=-m64 -L/opt/bb/lib64
-R/opt/bb/lib64''

Important settings:
value of $LANG: C
locale-coding-system: nil

Major mode: Info

Minor modes in effect:
desktop-save-mode: t
electric-pair-mode: t
show-paren-mode: t
delete-selection-mode: t
global-linum-mode: t
linum-mode: t
tooltip-mode: t
electric-indent-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
buffer-read-only: t
column-number-mode: t
line-number-mode: t
global-visual-line-mode: t
visual-line-mode: t
transient-mark-mode: t

Recent input:
C-x k <return> C-x C-b <help-echo> <help-echo> <help-echo> 
<help-echo> <help-echo> <help-echo> <menu-bar> <help-menu> 
<emacs-manual-bug> <help-echo> <down-mouse-1> <mouse-1> 
<down-mouse-1> <mouse-1> <help-echo> <help-echo> <down-mouse-1> 
<mouse-1> <help-echo> <down-mouse-1> <mouse-1> C-x 
2 M-x r e p o r t - e m a c s - b u g <return>

Recent messages:
Note: file is write protected
Using vacuous schema [3 times]
Wrote /home/rmunitz1/.emacs.d/.emacs.desktop.lock
Desktop: 1 frame, 15 buffers restored.
For information about GNU Emacs and the GNU system, type C-h C-a.
Updating buffer list...
Formats have changed, recompiling...done
Updating buffer list...done
Commands: m, u, t, RET, g, k, S, D, Q; q to quit; h for help

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
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 jka-compr info cl-macs ibuf-ext ibuffer
nxml-uchnm rng-xsd xsd-regexp rng-cmpct rng-nxml rng-valid rng-loc
rng-uri rng-parse nxml-parse rng-match rng-dt rng-util rng-pttrn nxml-ns
nxml-mode nxml-outln nxml-rap nxml-util nxml-glyph nxml-enc xmltok
vc-git cc-langs cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs view thai-util thai-word
mule-util lao-util zenburn-theme highlight-symbol easy-mmode cl gv
thingatpt desktop frameset cl-loaddefs cl-lib elec-pair paren delsel ido
linum 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 font-render-setting move-toolbar gtk
x-toolkit x multi-tty emacs)

Memory information:
((conses 16 284718 6555)
(symbols 48 35230 0)
(miscs 40 2895 633)
(strings 32 48468 7766)
(string-bytes 1 1308158)
(vectors 16 20642)
(vector-slots 8 690582 22734)
(floats 8 173 495)
(intervals 56 5319 732)
(buffers 960 28))