Subject: bug#17561: closed (Re: bug#17561: Emacs can forget processes)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 30 May 2014 21:30:06 +0000

Your bug report

#17561: 24.4.50; Emacs can forget processes

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
17561: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=17561
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#17561: Emacs can forget processes
From: Paul Eggert <[email-masked]>
To: Jorgen Schaefer <[email-masked]>
Cc: [email-masked]
Date: Fri, 30 May 2014 14:29:36 -0700
List-Id: <debbugs-submit.debbugs.gnu.org>

On 05/30/2014 01:41 PM, Jorgen Schaefer wrote:
> So I would assume that this bug is fixed, and if I come across weird
> behavior again, I'll create a new report or re-open this one.

Thanks, closing the bug.

> Possibly related, while trying to reproduce the bug, I have noticed
> some other strange behavior. I managed to reduce it to the following
> reproduction code:
>
> (with-temp-buffer
>    (let ((proc (start-process "test" (current-buffer) "bash" "-c"
>                               "echo foo ; sleep 5")))
>      (set-process-query-on-exit-flag proc nil)
>      (accept-process-output nil 2)))
>
> This hangs my normal Emacs for 2 seconds. A newly-started Emacs returns
> immediately. I*suspect*  that this is a timing issue, and strace
> *seems*  to concur - Emacs reads the "foo" from the subprocess before
> running accept-process-output, and then just hangs for the two second
> timeout, instead of noticing that there already was some output. Should
> I create a new bug report for this?

Yes, please.  It'd be nice to get an strace of Emacs, particularly where 
it goes wrong (which may be well before the symptoms start being visible).

Subject: 24.4.50; Emacs can forget processes
From: Jorgen Schaefer <[email-masked]>
To: [email-masked]
Date: Fri, 23 May 2014 17:52:35 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

>From time to time, my Emacs tends to become very slow. I have tracked
this down to a weird interaction with certain processes.

Sometimes, when a process dies (e.g. after its buffer is killed), Emacs
apparently does not clean up correctly. The sentinel is called, the
process itself receives a termination signal, but the process object
still shows up in M-x list-processes, and there is a zombie process in
ps.

When this happens, Emacs is in a tight loop trying to read from the dead
process(es):

21:24:00.948071 pselect6(12, [3 4 9 11], [], NULL, {0, 1376013},
                {NULL, 8}) = 2 (in [9 11], left {0, 1373467})
                <0.000011>
21:24:00.948529 read(9, "", 4096)       = 0 <0.000009>
21:24:00.948564 read(11, "", 4096)      = 0 <0.000008>

Killing the processes in M-x list-processes using
`process-menu-delete-process' returns Emacs to a usable state, albeit
the zombie processes stay around.

I have been able to reliably reproduce the behavior using this snippet:

(with-temp-buffer
  (let ((process-connection-type t))
    (set-process-query-on-exit-flag
     (start-process "cat" (current-buffer) "cat")
     nil)))

I.e. create a buffer, associate a process with it, remove the query on
exit flag, and kill the buffer. The `process-connection-type' nil is the
relevant part. With t, it works correctly.

The snippet does *not* work on a freshly-started Emacs. A random time
after the bug shows up, Emacs also cleans up the zombie processes and
the bug can not be triggered anymore. Until a whole while later, it
shows up again.

I have seen this happen in 24.3.50, 24.3.91 (pretest 2), and current
trunk.