From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "Basil L. Contovounesios" Newsgroups: gmane.emacs.bugs Subject: bug#33018: 26.1.50; thread starvation with async processes and accept-process-output Date: Tue, 16 Oct 2018 02:15:27 +0100 Message-ID: <877eiipu8g.fsf@tcd.ie> References: <87r2gwbmma.fsf@tcd.ie> <875zy7cqzd.fsf@gmx.de> <878t30h823.fsf@tcd.ie> <87sh177i36.fsf@gmx.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: blaine.gmane.org 1539652452 14257 195.159.176.226 (16 Oct 2018 01:14:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 16 Oct 2018 01:14:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 33018@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Oct 16 03:14:07 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 1gCDvx-0003WO-3a for geb-bug-gnu-emacs@m.gmane.org; Tue, 16 Oct 2018 03:14:05 +0200 Original-Received: from localhost ([::1]:55466 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCDy3-0001gm-4y for geb-bug-gnu-emacs@m.gmane.org; Mon, 15 Oct 2018 21:16:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gCDxt-0001ge-U0 for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 21:16:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gCDxq-0007YW-LS for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 21:16:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47385) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gCDxq-0007XQ-5Y for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 21:16:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gCDxp-0006Bx-L5 for bug-gnu-emacs@gnu.org; Mon, 15 Oct 2018 21:16:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: "Basil L. Contovounesios" Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 16 Oct 2018 01:16:01 +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.153965254423776 (code B ref 33018); Tue, 16 Oct 2018 01:16:01 +0000 Original-Received: (at 33018) by debbugs.gnu.org; 16 Oct 2018 01:15:44 +0000 Original-Received: from localhost ([127.0.0.1]:51643 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCDxX-0006BQ-US for submit@debbugs.gnu.org; Mon, 15 Oct 2018 21:15:44 -0400 Original-Received: from mail-ed1-f47.google.com ([209.85.208.47]:37602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gCDxV-0006BB-4A for 33018@debbugs.gnu.org; Mon, 15 Oct 2018 21:15:42 -0400 Original-Received: by mail-ed1-f47.google.com with SMTP id c22-v6so19653508edc.4 for <33018@debbugs.gnu.org>; Mon, 15 Oct 2018 18:15:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tcd-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=Qu5NrC7ZxHOFneqBJimL1EW028BtpdtZs1JiIJxZQDU=; b=OUPKfWOi09riNKml4/YhCEoTgmILvU9HjgtU2Q8ZPZ80sqmFre40i4zhCHmgs+uMwJ 6opHdInz7cNw5mLcXy0KiNVETQ/nXKR981JOQ6LuyLTXmp+di3IfOCN+0i/yu2T5Yk/z oJFjPd5veeVHAqkI6oiScl4n7MppLln0VoFXOxY1pg+sBGfVAUuljojO4maZhb1y+Z4+ 8rOWzAiBQp+stZznN40JcmJGw1lltIkW0vX7uFoRCIYSGir1/yBTj2Qts8RZkyWv7L62 4DY1o3PsiW4o2UYQeMCjnyN10woE1PzRcEIe/qJjLm9yIFLDmpdaEQ5oEU/zFRDEZMI/ 8n/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=Qu5NrC7ZxHOFneqBJimL1EW028BtpdtZs1JiIJxZQDU=; b=sW2+xfIYsKFyWN16o9Y8NLFwWiXD0Tm91scxNVDis4kToRbd2mro7J8h4FCPtKwwKR Nek/UPvCTqg5F/5RtsfVLLAD10zeb2kVJyOXbw8x1PCdYKLqKy9oxvpz/FYuge36LPZf RljDnTUp/If9YXG7imEW8lBvaTa23AQpHmaaOumslJ5pFeTabTywT1iHOLfpnGOEDrp7 D3Il3ZJtz9RN4Z6KlR77q5vdEu3BsgzzSAhWDtFfcKyV9Vk+xhfEl4OzIBehnO7RK4em X95ORABZOXPuUiGPc0aH0V8Hcb3UkYW1eG53lSfKPVk9hWpXnSCQKwEi/h03QVnbIX6a Kqbw== X-Gm-Message-State: ABuFfoi6Q5n1J5GwpcIkL4VUkokH3pssvoGDYFkSNCzb6p0LZvgXVhrN 8mZS+mf5DlPZpnOrE0iwl1Qx5g== X-Google-Smtp-Source: ACcGV604jjEz3ELxeKcuiQ6Nsru2JXZfoHNcep5yFh/1uQBUQbZzTsViflFdutkeU407SslcHJ11Pg== X-Received: by 2002:a50:d78b:: with SMTP id w11-v6mr28672589edi.19.1539652535019; Mon, 15 Oct 2018 18:15:35 -0700 (PDT) Original-Received: from localhost (51-171-243-2-dynamic.agg2.clk.blp-srl.eircom.net. [51.171.243.2]) by smtp.gmail.com with ESMTPSA id y47-v6sm5801266edc.27.2018.10.15.18.15.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Oct 2018 18:15:34 -0700 (PDT) In-Reply-To: <87sh177i36.fsf@gmx.de> (Michael Albinus's message of "Mon, 15 Oct 2018 10:02:53 +0200") 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:151296 Archived-At: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: attachment; filename=test.el Content-Transfer-Encoding: quoted-printable ;;; test.el --- test -*- lexical-binding: t -*- ;;; Code: (defun test-debug (&rest args) "Print `current-thread' and ARGS in timestamped `message'." (push (current-thread) args) (message "[%s] %s" (format-time-string "%T:%3N") (mapconcat #'prin1-to-string 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/Emac= s") :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 (dotimes (_ 2) (let (threads) (dotimes (i 2) (push (make-thread #'test-slave (format "test-%d" i)) threads)) (mapc #'thread-join threads))) (dotimes (_ 2) (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 --=-=-= Content-Type: text/plain Michael Albinus writes: > 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. Thanks, creating all threads before waiting for any of them to exit indeed does not suffer from the same hang. Doing this twice (see attached update), however, still hangs. There's something about going through a complete create-join cycle more than once within a non-main-thread which is triggering this behaviour. -- Basil --=-=-=--