From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Vitalie Spinu Newsgroups: gmane.emacs.bugs Subject: bug#13290: 24.2.91; [PATCH] Comint can stall emacs with non-trivial input senders Date: Thu, 27 Dec 2012 22:49:01 +0100 Message-ID: <87y5gj2mk2.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1356645022 9155 80.91.229.3 (27 Dec 2012 21:50:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 27 Dec 2012 21:50:22 +0000 (UTC) To: 13290@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 27 22:50:38 2012 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 1ToLLZ-0002dT-GL for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Dec 2012 22:50:37 +0100 Original-Received: from localhost ([::1]:37991 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToLLL-0007uO-69 for geb-bug-gnu-emacs@m.gmane.org; Thu, 27 Dec 2012 16:50:23 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:56090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToLLE-0007tA-UY for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 16:50:21 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ToLLB-00041A-WB for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 16:50:16 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52082) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToLLB-00040z-Sc for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 16:50:13 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1ToLLy-00010S-LC for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 16:51:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Vitalie Spinu Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 27 Dec 2012 21:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13290 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13566450063788 (code B ref -1); Thu, 27 Dec 2012 21:51:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Dec 2012 21:50:06 +0000 Original-Received: from localhost ([127.0.0.1]:34099 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ToLL4-0000z2-1b for submit@debbugs.gnu.org; Thu, 27 Dec 2012 16:50:06 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44423) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1ToLL2-0000yw-HB for submit@debbugs.gnu.org; Thu, 27 Dec 2012 16:50:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ToLKB-0003Nx-6i for submit@debbugs.gnu.org; Thu, 27 Dec 2012 16:49:15 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:47565) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToLKB-0003Nj-3J for submit@debbugs.gnu.org; Thu, 27 Dec 2012 16:49:11 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToLK8-0007mO-DU for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 16:49:11 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ToLK5-0003Lr-Gx for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 16:49:08 -0500 Original-Received: from mail-wg0-f43.google.com ([74.125.82.43]:47852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ToLK5-0003LR-Ax for bug-gnu-emacs@gnu.org; Thu, 27 Dec 2012 16:49:05 -0500 Original-Received: by mail-wg0-f43.google.com with SMTP id e12so4630546wge.22 for ; Thu, 27 Dec 2012 13:49:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=27drVgcSOz+PZkHNrRvG7SradUZVbktBAvC50LBcDZ0=; b=vyJXoQU/oyWH+H/hYL0Yz0Jolr9+OUV2R2T22V1tNasRx9Pl4IIGEkn423t7gNl+16 ZEoM/J13u3w03RXAloiB5yQcl1W208XQbUzql/jM4T/XJzjE+EiwN1BOYdiRtw6fdVXB FWBroEy0w9sQd0jolvpCIHjaHKJNrlkHr+BOvtZ7DbvBrGzTiYg5mvJMIlGZv0nUuMSp 93Ip0uyCs/TZwr8doJ5SZjY3tf7W2TWL88cYrTelpDqmSpfR7k06XJJbTNsLaWK95kd6 STxHJA1XyyMQhtzuZdqX2DIi7WS2tiRbsjqwCupn1F1334YJEcSeUCv4H2UFpWAzgU4q bl7Q== X-Received: by 10.180.78.66 with SMTP id z2mr42016437wiw.23.1356644944106; Thu, 27 Dec 2012 13:49:04 -0800 (PST) Original-Received: from localhost (i108036.upc-i.chello.nl. [62.195.108.36]) by mx.google.com with ESMTPS id hu8sm37305233wib.6.2012.12.27.13.49.02 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 27 Dec 2012 13:49:03 -0800 (PST) User-Agent: Gnus/5.130004 (Ma Gnus v0.4) Emacs/24.2.91 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.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:69087 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi,=20 Comint can stall emacs while waiting for subproces output. I attach a trivial patch. Here is a short explanation. First comint calls comint-input-sender=20 =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #1842 =E2=94=80 /home/vitoshka/TVC/emacs/lisp/comint.el =E2=94=80=E2= =94=80 =E2=94=82 (let ((comint-input-sender-no-newline no-newline)) =E2=94=82 (funcall comint-input-sender proc input)) =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #1843 =E2=94=80 Then, if process echoes, comint first waits for process output: =E2=95=AD=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #1850 =E2=94=80 /home/vitoshka/TVC/emacs/lisp/comint.el =E2=94=80=E2= =94=80 =E2=94=82 (while (and (accept-process-output proc) =E2=94=82 (> (+ comint-last-input-end echo-len) =E2=94=82 (point-max)) =E2=95=B0=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2=94=80=E2= =94=80 #1852 =E2=94=80 The problem is that, occasionally, comint-input-sender might be a non-trivial function and could take care of process output itself. Thus, accept-process-output will wait for nonexistent output, and stall emacs. The patch just reverts the order in the (and ...) above. Thanks,=20 Vitalie --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Avoid-hanging-emacs-by-complex-comint-input-senders.patch >From d3c2753a571688370a4bc8fa2254679d9c23b74a Mon Sep 17 00:00:00 2001 From: Vitalie Spinu Date: Thu, 27 Dec 2012 21:46:38 +0100 Subject: [PATCH] Avoid hanging emacs by complex comint input senders. Revert the order of echo-len check and accept-process-output to avoid stalling Emacs when there is no process output left. --- lisp/ChangeLog | 6 ++++++ lisp/comint.el | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5f4853d..cc94b0d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2012-12-27 Vitalie Spinu + + * comint.el (comint-send-input): revert the order of echo-len + check and accept-process-output to avoid hanging Emacs when there + is no process output left. + 2012-12-27 Michael Albinus * net/tramp.el (tramp-handle-file-accessible-directory-p): New defun. diff --git a/lisp/comint.el b/lisp/comint.el index f3450e3..6477f00 100644 --- a/lisp/comint.el +++ b/lisp/comint.el @@ -1847,9 +1847,9 @@ Similarly for Soar, Scheme, etc." (let ((echo-len (- comint-last-input-end comint-last-input-start))) ;; Wait for all input to be echoed: - (while (and (accept-process-output proc) - (> (+ comint-last-input-end echo-len) + (while (and (> (+ comint-last-input-end echo-len) (point-max)) + (accept-process-output proc) (zerop (compare-buffer-substrings nil comint-last-input-start -- 1.7.10.4 --=-=-= Content-Type: text/plain In GNU Emacs 24.2.91.1 (i686-pc-linux-gnu, GTK+ Version 2.24.13) of 2012-12-25 on vitoshka-home Windowing system distributor `The X.Org Foundation', version 11.0.11300000 System Description: Ubuntu 12.10 Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix default enable-multibyte-characters: t --=-=-=--