Subject: Re: Emacs can forget processes

From: Jorgen Schaefer <[email-masked]>
Date: Tue, 27 May 2014 20:27:56 +0200

On Mon, 26 May 2014 16:58:45 -0700
Paul Eggert <[email-masked]> wrote:

> Jorgen Schaefer wrote:
> > the-bug.txt.gz ... shows the strace of a
> > running Emacs session which starts to exhibit the bug, so we now
> > have a trace that includes the time when the bug actually happens.
> > It shows me starting Python subprocesses (elpy RPC processes) and
> > killing them, in an attempt to reproduce the problem. Eventually,
> > this succeeds, and Emacs goes into the loop reading from fd 15.
> 
> Thanks for that trace; it's helpful.  A couple of things.  First,
> what platform are you running on, exactly?  I'm running on an AMD
> Phenom II X4 910e (according to /proc/cpuinfo), and using Fedora 20
> x86-64 (Linux kernel 3.14.4-200.fc20.x86_64, glibc 2.18), and
> compiling with GCC 4.9.0.

Thanks for making me check that. There was a bit of a wtf there for
me :-D The strace is from an OpenVZ virtual host:

Debian GNU/Linux 7.5 (wheezy)
Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz
Linux kernel 3.2.41-042stab085.20
eglibc 2.13

Note the embedded glibc. 

I have seen a similar behavior (Emacs suddenly responding badly,
improving once processes are killed) on this type of system:

openSUSE 12.2 (x86_64)
Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz
Linux kernel 3.4.63-2.44-desktop
glibc-2.15
gcc 4.7.1

But I can't know for sure if it's the same bug.

> Second, looking at the-bug.txt I'm suspicious about the interaction 
> between vfork, pthread_sigmask (aka rt_sigprocmask) and rt_sigreturn. 
> Could you please try building Emacs with fork rather than vfork and
> see whether that fixes the problem?  If it fixes things, great; if
> not I'd like to see another strace of the bug.  To use fork instead
> of vfork, you can run "./configure ac_cv_func_fork_works=no", or
> (faster but flimsier) edit src/config.h to add "#define fork vfork".

Should that be ac_cv_func_vfork_works=no? I have no recompiled Emacs
with the latter change, and it's using clone(2) to execute processes,
which sounds right. I haven't been able to reproduce the bug so far,
sadly that doesn't say much, I have gone for over a week before without
noticing the bug until it reappeared.

Regards,
Jorgen