Subject: bug#33018: 26.1.50; thread starvation with async processes and accept-process-output

From: Michael Albinus <[email-masked]>
Date: Tue, 16 Oct 2018 15:54:02 +0200

"Basil L. Contovounesios" <[email-masked]> writes:

> There's something about going through a complete create-join cycle more
> than once within a non-main-thread which is triggering this behaviour.

I'm not sure that it is related to threads. It looks, like some of your
processes do not exit properly, and then thread-join is blocked.

I've modified your example, again. It runs perfectly. And during its
work, you could call "M-x list-threads" and see how the threads are
created and die.

Best regards, Michael.

diff -u /home/albinus/tmp/test.el.\~1\~ /home/albinus/tmp/test.el
--- /home/albinus/tmp/test.el.~1~	2018-10-16 14:46:47.000000000 +0200
+++ /home/albinus/tmp/test.el	2018-10-16 15:47:05.581276541 +0200
@@ -19,9 +19,9 @@
 (defun test-slave ()
   "Create an asynchronous process and wait for it to exit."
   (let ((proc (make-process
-               :name "test"
+               :name (thread-name (current-thread))
                :buffer (generate-new-buffer " *test*")
-               :command '("wget" "-qO-" "https://en.wikipedia.org/wiki/Emacs")
+               :command `("echo" ,(thread-name (current-thread)))
                :connection-type 'pipe
                :sentinel #'test-sentinel)))
     (while (eq (process-status proc) 'run)
@@ -32,10 +32,10 @@
   "Successively run `test-slave'.
 With non-nil ASYNC, use a new thread for each invocation."
   (if async
-      (dotimes (_ 2)
+      (dotimes (i 100)
         (let (threads)
-          (dotimes (i 2)
-            (push (make-thread #'test-slave (format "test-%d" i)) threads))
+          (dotimes (j 100)
+            (push (make-thread #'test-slave (format "test-%d-%d" i j)) threads))
           (mapc #'thread-join threads)))
     (dotimes (_ 2)
       (test-slave))))