Subject: Re: Emacs can forget processes

From: Jorgen Schaefer <[email-masked]>
Date: Fri, 23 May 2014 18:44:19 +0200

On Fri, 23 May 2014 09:28:44 -0700
Paul Eggert <[email-masked]> wrote:

> How was Emacs configured and built on your platform? What's your
> platform?

I have seen this bug happen on a Debian 7.5 Wheezy x86_64 with an
Emacs configured with --without-x and an openSUSE 12.3 amd64 with
a GUI version (can't currently check which toolkit it uses by default
there).

> Can you run the shell command 'strace -p' on an Emacs with the
> problem, and trace the system calls near the offending area?

The bug report includes an strace output. Emacs does the pselect6 call
and then read calls for all "broken" sockets in a tight loop, and
pretty much nothing else.

> Are you using anything involving SIGUSR1 or SIGUSR2?  I see an
> unlikely race condition there.

Not to my knowledge, unless Emacs sends those signals in some situation
without it being obvious; I do not send any signals myself, all I do is
use `kill-buffer' and `delete-process'.

> That's part of the problem with this code: it's so racy that it seems 
> that every time I look at it I find another unlikely race condition. 
> I'm attaching a patch to emacs-24 for the unlikely races I found in a 
> quick look at the area, not that I think it'll fix your problem.  I 
> haven't installed this.

read(2) returning 0 indicates an EOF (which pselect6 indicates as
waiting input), I suspect there could at least be a sanity check here
to close the file descriptors instead of continuously polling.

Regards,
Jorgen