From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#19860: 25.0.50; One url-retrieve-synchronously call running concurrently with another can freeze it Date: Sat, 25 Apr 2015 16:19:52 -0700 Organization: UCLA Computer Science Department Message-ID: <553C2118.4080106@cs.ucla.edu> References: <86bnkxnyju.fsf@yandex.ru> <553A3489.6080504@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020608070609030905080107" X-Trace: ger.gmane.org 1430004338 9921 80.91.229.3 (25 Apr 2015 23:25:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 25 Apr 2015 23:25:38 +0000 (UTC) To: Dmitry Gutov , 19860-done@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Apr 26 01:25:27 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Ym9Rv-0007Ub-FO for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Apr 2015 01:25:27 +0200 Original-Received: from localhost ([::1]:49490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym9Ru-00023P-CN for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Apr 2015 19:25:26 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:41639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym9Rl-000227-4G for bug-gnu-emacs@gnu.org; Sat, 25 Apr 2015 19:25:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ym9Ne-000461-V4 for bug-gnu-emacs@gnu.org; Sat, 25 Apr 2015 19:25:17 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:50248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ym9Ne-00045v-Rl for bug-gnu-emacs@gnu.org; Sat, 25 Apr 2015 19:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Ym9Ne-0006fe-Lv for bug-gnu-emacs@gnu.org; Sat, 25 Apr 2015 19:21:02 -0400 Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Apr 2015 23:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 19860 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 19860@debbugs.gnu.org, eggert@cs.ucla.edu, dgutov@yandex.ru Original-Received: via spool by 19860-done@debbugs.gnu.org id=D19860.143000401025567 (code D ref 19860); Sat, 25 Apr 2015 23:21:02 +0000 Original-Received: (at 19860-done) by debbugs.gnu.org; 25 Apr 2015 23:20:10 +0000 Original-Received: from localhost ([127.0.0.1]:40022 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ym9Mm-0006eH-LD for submit@debbugs.gnu.org; Sat, 25 Apr 2015 19:20:09 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:46548) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Ym9Mj-0006dj-B0 for 19860-done@debbugs.gnu.org; Sat, 25 Apr 2015 19:20:06 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id A6BC639E8014; Sat, 25 Apr 2015 16:19:58 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NpWpIAomj27R; Sat, 25 Apr 2015 16:19:57 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id B45EB39E8013; Sat, 25 Apr 2015 16:19:57 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 In-Reply-To: <553A3489.6080504@yandex.ru> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:102040 Archived-At: This is a multi-part message in MIME format. --------------020608070609030905080107 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Dmitry Gutov wrote: > 'git bisect' points to 12dc5429352223f7ba8314d2e16177036a762733. > > Paul, could you look into this? Thanks for doing all that legwork. It let me reproduce the problem and come up with a simple fix that works for me. I installed the attached patch. --------------020608070609030905080107 Content-Type: text/x-patch; name="0001-Don-t-freeze-with-unreadable-processes.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Don-t-freeze-with-unreadable-processes.patch" >From 9ca712e2689f1875d7facd229f2cb1916719cf49 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 25 Apr 2015 16:16:58 -0700 Subject: [PATCH] Don't freeze with unreadable processes Don't freeze if an exiting process can't be read from. (Bug#19860). This fixes a bug I introduced in 2014-07-08T07:24:07Z@eggert@cs.ucla.edu "* process.c: Add sanity checks for file descriptors." Dmitry Gutov did most of the legwork in finding the problem. * src/process.c (wait_reading_process_output): Treat non-running processes that can't be read from the same as other non-running processes. --- src/process.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/process.c b/src/process.c index c745507..3e04cb7 100644 --- a/src/process.c +++ b/src/process.c @@ -4785,37 +4785,41 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd, if (wait_proc && wait_proc->raw_status_new) update_status (wait_proc); if (wait_proc - && wait_proc->infd >= 0 && ! EQ (wait_proc->status, Qrun) && ! EQ (wait_proc->status, Qconnect)) { bool read_some_bytes = false; clear_waiting_for_input (); - XSETPROCESS (proc, wait_proc); - /* Read data from the process, until we exhaust it. */ - while (true) + /* If data can be read from the process, do so until exhausted. */ + if (wait_proc->infd >= 0) { - int nread = read_process_output (proc, wait_proc->infd); - if (nread < 0) + XSETPROCESS (proc, wait_proc); + + while (true) { - if (errno == EIO || errno == EAGAIN) - break; + int nread = read_process_output (proc, wait_proc->infd); + if (nread < 0) + { + if (errno == EIO || errno == EAGAIN) + break; #ifdef EWOULDBLOCK - if (errno == EWOULDBLOCK) - break; + if (errno == EWOULDBLOCK) + break; #endif - } - else - { - if (got_some_input < nread) - got_some_input = nread; - if (nread == 0) - break; - read_some_bytes = true; + } + else + { + if (got_some_input < nread) + got_some_input = nread; + if (nread == 0) + break; + read_some_bytes = true; + } } } + if (read_some_bytes && do_display) redisplay_preserve_echo_area (10); -- 2.1.4 --------------020608070609030905080107--