Subject: Emacs 23.2.1: exiting last `emacsclient -c' frame, and then rerun client, segfaults `emacs --daemon'

From: Chen Levy <[email-masked]>
Date: Sat, 2 Oct 2010 15:12:56 +0200

Description:
=======

When starting emacs server with `emacs --daemon', and connecting to it with
`emacsclient -c', then closing the last `emacsclient -c' frame and trying to
open a new `emacsclient -c' frame, the `emacs --daemon'
process receive SYSSEGV.

Steps to reproduce:
============

0. Make sure no Emacs processes are running.

1. Run: emacs --daemon
  It prints:
  ("emacs")
  Starting Emacs daemon.

  and the process starts normally.

2. Run: emacsclient -c
  It prints: Waiting for Emacs...
  and a new frame opens as expected.

3. Close the frame, started on strep 2.
  Observe that the `/tmp/emacs${UID}/server' socket seem to be active.
  `fuser' on it prints the `emacs --daemon' PID.

4. (optional) Open `gdb', `attach' to the `emacs --daemon' process, and
`continue' it.

5. Run: emacsclient -c
  It prints: Waiting for Emacs...
  but no new frame is opened.

  gdb prints something like:
  Program received signal SIGSEGV, Segmentation fault.
  0x00007f989f211527 in kill () from /lib/libc.so.6

  And the output of `fuser /tmp/emacs${UID}/server' confirms that the socket
is stale.

6. Run: `emacsclient -c' prints:
  emacsclient: connect: Connection refused
  emacsclient: No socket or alternate editor.  Please use:

          --socket-name
          --server-file      (or environment variable EMACS_SERVER_FILE)
          --alternate-editor (or environment variable ALTERNATE_EDITOR)

Version information:
============

# (version)
GNU Emacs 23.2.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.12.9)
(compiled from source)

# uname -a
Linux xxxxxx 2.6.24-28-generic #1 SMP Thu Sep 16 14:18:43 UTC 2010 x86_64
GNU/Linux

# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.4 LTS"

See also:
======

http://superuser.com/questions/194395/why-does-tmp-emacsuid-server-get-stale-after-last-emacsclient-exits

| Cheers,
| Chen.