From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.bugs Subject: bug#33018: 26.1.50; thread starvation with async processes and accept-process-output Date: Mon, 15 Oct 2018 10:02:53 +0200 Message-ID: <87sh177i36.fsf@gmx.de> References: <87r2gwbmma.fsf@tcd.ie> <875zy7cqzd.fsf@gmx.de> <878t30h823.fsf@tcd.ie> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1539590538 1934 195.159.176.226 (15 Oct 2018 08:02:18 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 15 Oct 2018 08:02:18 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 33018@debbugs.gnu.org To: "Basil L. Contovounesios" Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 15 10:02:14 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBxpN-0000Na-VI for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Oct 2018 10:02:14 +0200 Original-Received: from localhost ([::1]:50907 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBxrU-0000pT-2P for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Oct 2018 04:04:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35854) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gBxrC-0000oI-UX for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 04:04:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gBxr8-0003sq-W6 for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 04:04:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:45496) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gBxr8-0003sI-OL for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 04:04:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gBxr8-0004Ih-BP for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 04:04:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Albinus Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 15 Oct 2018 08:04:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33018 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33018-submit@debbugs.gnu.org id=B33018.153959058316463 (code B ref 33018); Mon, 15 Oct 2018 08:04:02 +0000 Original-Received: (at 33018) by debbugs.gnu.org; 15 Oct 2018 08:03:03 +0000 Original-Received: from localhost ([127.0.0.1]:49754 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBxqB-0004HT-HO for submit@debbugs.gnu.org; Mon, 15 Oct 2018 04:03:03 -0400 Original-Received: from mout.gmx.net ([212.227.15.19]:50787) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gBxq9-0004Gz-WE for 33018@debbugs.gnu.org; Mon, 15 Oct 2018 04:03:02 -0400 Original-Received: from detlef.gmx.de ([212.86.50.126]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M2t0Q-1fKgzg3Ilq-00sih9; Mon, 15 Oct 2018 10:02:54 +0200 Original-Received: from detlef.gmx.de ([212.86.50.126]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M2t0Q-1fKgzg3Ilq-00sih9; Mon, 15 Oct 2018 10:02:54 +0200 In-Reply-To: <878t30h823.fsf@tcd.ie> (Basil L. Contovounesios's message of "Sun, 14 Oct 2018 16:17:08 +0100") X-Provags-ID: V03:K1:Qpnh7mnRu8gLYavULjdmsgd4ECgrnOZHm9C8C5b+M6d/JBuBEhk XCUxQ0MCnsE22ccZT5x4Op3+tH+4boJbEvmTu+S7btIC1/K5xBXffAdIeoNLs6ZnuP4wg62 cx/aagAArvU+L3yGpxveIN62cjzKuAf1B/Ykzb4mwD+m7TY2ZaBUivI51+OheL0biqRYDbL 70B4j9905VtdUW0wRTDHg== X-UI-Out-Filterresults: notjunk:1;V01:K0:Y8pTnWUnAlc=:R+jz4/EE2fW6NMVXGPRDzP 7qk1hU2VQfKRZNB0vGWfKNW2Gf/cE00NkeSJBP71k4d9t7nECwj4itHB2Aj16aayEaJzkAo// 8yBJ8saY2bP7bc5eT/XO++LYqHo97MkBmUt+h8Ixu1QGIXj6jWdl/ZALedk7+M0+CNbEuz2+Z NxLK8TANIEda8CQKCsbpv7dsasIkn/W5PuyAxIbP3nmAwg9NAFUxA8YHaanuwp0ip4W3zcN5I 6o6qbv4wlhOWPX7HCjH7dcariD2iMy1d29s7afC9ws2/zvKK3TFld8rBRrZLCiN4aKEC8JAKd RUa14sUrrZtQCeS7RROKuMDKDKk/LXJ/TMhoVDXucKLHpjMD1+rS/4R7N42/qb0onnvK7Jmnn pW8XTyB95xGG+GoMKBC1FGksEb6pEH/rDcj1xeLQ2o5d8bzxzrlcR8aX8x799DTjF5onu3QOy 5yqaPHdI2B4/2Q2nmn+g92K91cloSgR2tCYH4338kFEbquDJnOWAEEzw52xHFS5+RiNLy0Jzz i+iXPAtKsH5P35jNYCuvGG06urkM3dBCx5171vU0kMNRFDriPiXGoknOK0fcKwmSJJ/5Sc1F4 poKvcwRrWa8hiVrO8SkfEn5TXWPEcbPooSrZIOMrGkRkkD9D9OwxfKlVcs0S8J5Q28pB7g3ci OD3iSkELm0dEtXrIOGwRcWmzrNqxqMsPkQJ5JpEp6v9m0bEXOC1Z7Ou1ubmURp1tyj9PQVOgu PgmUchmpl/3yqNvZBHuTWVqK+HkxMkoWv1K6zrJryj15ejbV4imcJcmvvDMjhkzlHZ84Tkso X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:151258 Archived-At: --=-=-= Content-Type: text/plain "Basil L. Contovounesios" writes: Hi Basil, >> If you want a process to communicate in a given thread, you must call >> `set-process-thread'. See the elisp manual. > > Thanks, this is the first thing I tried when earlier experiments started > to hang. I tried both the following redundant but explicit call: Well, I've played with your example. As Eli said, `set-process-thread' is not needed here. With your original example, I could reproduce the problem, However, if I call emacs -l test.el -f test-threads the problem does NOT happen. My .emacs is quite long, so I didn't bisect in order to find out what makes the difference. I have changed your example a little bit wrt `thread-join', see appended. This version runs w/o any problem even if emacs is called with -Q. Maybe this helps you to debug further. Best regards, Michael. --=-=-= Content-Type: text/plain Content-Disposition: attachment ;;; test.el --- test -*- lexical-binding: t -*- ;;; Code: (defun test-debug (proc &rest args) "Print `current-thread' and ARGS in timestamped `message'." (message "[%s] %s" (format-time-string "%T:%3N") (mapconcat #'prin1-to-string `(,(current-thread) ,(process-thread proc) ,@args) " "))) (defun test-sentinel (proc msg) "Kill buffer of PROC when it exits." (test-debug proc 'sentinel (process-status proc) (substring msg 0 -1)) (and (not (eq (process-status proc) 'run)) (buffer-live-p (process-buffer proc)) (kill-buffer (process-buffer proc)))) (defun test-slave () "Create an asynchronous process and wait for it to exit." (let ((proc (make-process :name "test" :buffer (generate-new-buffer " *test*") :command '("wget" "-qO-" "https://en.wikipedia.org/wiki/Emacs") :connection-type 'pipe :sentinel #'test-sentinel))) (while (eq (process-status proc) 'run) (test-debug proc 'accept-output (accept-process-output proc 5))) (test-debug proc 'exit (process-status proc) (process-exit-status proc)))) (defun test-master (async) "Successively run `test-slave'. With non-nil ASYNC, use a new thread for each invocation." (if async (progn (dotimes (i 5) (make-thread #'test-slave (format "test-%d" i))) (while (cdr (all-threads) (thread-join (cadr (all-threads)))))) (dotimes (i 5) (test-slave)))) (defun test-job (async) "Successively run `test-slave'. Like `test-master', but avoid blocking interactive sessions by running `test-master' in its own thread." (if noninteractive (test-master async) (make-thread (apply-partially #'test-master async) "test-master"))) (defun test-threads () "Run `test-master' with threads." (test-job t)) (defun test-no-threads () "Run `test-master' without threads." (test-job nil)) ;;; test.el ends here --=-=-=--