Subject: bug#38035: 27.0.50; Trivial errors in process filters can render Emacs unusable

From: Eli Zaretskii <[email-masked]>
Date: Sat, 02 Nov 2019 20:36:03 +0200

> From: Lars Ingebrigtsen <[email-masked]>
> Date: Sat, 02 Nov 2019 18:53:57 +0100
> 
> (let ((process (start-process
> 		"foo" (get-buffer-create "*foo*")
> 		"bash" "-c" "while true; do echo foo; sleep 1; done")))
>   (set-process-filter
>    process
>    (lambda (&rest _)
>      (error))))
> 
> The reason for this is that when signalling an error from a process
> filter, Emacs messages the error message and then seems to sleep for a
> second?

Yes, see read_process_output_error_handler (it's actually 2-sec
sleep), and read_and_dispose_of_process_output, where we set up for
calling the process filter.

> I'm not sure what solution would be best.  I see two obvious things we
> could do: Remove the process filter, so that it doesn't trigger again.
> Or -- remove the one-second sleep, which would allow the user to `M-x
> list-processes' and kill the offending process.

I'd suggest to count the number of times a process filter errors out,
and disable it after some configurable number.  Doing that on the
first error sounds too drastic: it could be a one-time spurious error.