GNU bug report logs - #13400
23.4; overlapping process filter calls

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Hendrik Tews <hendrik@HIDDEN>; dated Thu, 10 Jan 2013 10:13:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 10 Jan 2013 10:12:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 10 05:12:09 2013
Received: from localhost ([127.0.0.1]:53354 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1TtF7J-0002Hs-4K
	for submit <at> debbugs.gnu.org; Thu, 10 Jan 2013 05:12:09 -0500
Received: from eggs.gnu.org ([208.118.235.92]:60425)
	by debbugs.gnu.org with esmtp (Exim 4.72)
	(envelope-from <tews@HIDDEN>) id 1TtF7F-0002HM-VN
	for submit <at> debbugs.gnu.org; Thu, 10 Jan 2013 05:12:07 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <tews@HIDDEN>) id 1TtF74-000662-Sn
	for submit <at> debbugs.gnu.org; Thu, 10 Jan 2013 05:12:00 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00
	autolearn=unavailable version=3.3.2
Received: from lists.gnu.org ([208.118.235.17]:42960)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tews@HIDDEN>) id 1TtF74-00065u-PR
	for submit <at> debbugs.gnu.org; Thu, 10 Jan 2013 05:11:54 -0500
Received: from eggs.gnu.org ([208.118.235.92]:43538)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tews@HIDDEN>) id 1TtF70-00079j-J4
	for bug-gnu-emacs@HIDDEN; Thu, 10 Jan 2013 05:11:54 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <tews@HIDDEN>) id 1TtF6w-000652-7w
	for bug-gnu-emacs@HIDDEN; Thu, 10 Jan 2013 05:11:50 -0500
Received: from srv4.sysproserver.de ([78.138.89.57]:41927)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <tews@HIDDEN>) id 1TtF6v-00063p-Ud
	for bug-gnu-emacs@HIDDEN; Thu, 10 Jan 2013 05:11:46 -0500
Received: from wallace.tews.net (146-52-255-95-dynip.superkabel.de
	[146.52.255.95])
	(using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits))
	(No client certificate requested)
	by srv4.sysproserver.de (Postfix) with ESMTPSA id 95892C74003;
	Thu, 10 Jan 2013 11:11:43 +0100 (CET)
Received: from tews by wallace.tews.net with local (Exim 4.80)
	(envelope-from <tews@HIDDEN>)
	id 1TtF6s-0001VR-HY; Thu, 10 Jan 2013 11:11:42 +0100
From: Hendrik Tews <hendrik@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 23.4; overlapping process filter calls
Date: Thu, 10 Jan 2013 11:11:42 +0100
Message-ID: <87r4ltpctd.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x
X-Received-From: 208.118.235.17
X-Spam-Score: -6.9 (------)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.13
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.9 (------)

Hi,

because Stefan Monnier asked for it
(http://lists.inf.ed.ac.uk/pipermail/proofgeneral-devel/2013/000296.html):

When a process filter does I/O (eg, process-send-string), it
might happen, that the same filter is called again for the same
process, while the first instance blocks. To reproduce, load the
code below and do M-x double-filter.

The problem is real with Coq Proof General and Prooftree. There,
Prooftree is driven from a process filter in Proof General. With
cold disk caches, it takes about 1 sec to start Prooftree (at
least on my laptops). Coq and Proof General easily fill the pipe
in that time, so that the process filter blocks inside
process-send-string. Meanwhile Coq continues to produce output
and the process filter is called again while the previous call
has not finished.

The more I think about it, I believe this is a feature. 

However, the documentation is sometimes wrong and could be
clearer about this feature:

- Section "37.9 Receiving Output from Processes" does not list
  process-send-string. How about other blocking I/O functions?

- Same in "37.9.2. Process Filter Functions"

- Same in "37.4 Creating an Asynchronous Process" ,
  process-send-string is neither waiting for input not time
  delay.

- "37.7 Sending Input to Processes" says that filters can run
  inside process-send-string, but it could be clearer about the
  point that this can also happen inside the same filter for the
  same process.

- "37.9.2 Process Filter Functions" ignores the problem
  completely. There should be a paragraph clearly stating this
  problem. Further, it would be nice, if the filter function
  example could be extended to correctly deal with this problem.


To make it easier in the future to deal with this problem, I
suggest to add a process specific flag
``process-no-concurrent-filters''. When this flag is t for a
process, Emacs accepts output from this process inside a filter
but buffers it without calling the filter. The call to the filter
is delayed until a point where no filter for this process is
running. An error is signaled, if the buffered output exceeds a
certain size.


===========================================================================
(defun double-filter ()
  (interactive)
  (setq df-process (start-process "tee" nil "/bin/cat"))
  (set-process-filter df-process 'df-filter)
  (set-process-sentinel df-process 'df-sentinel)
  (set-process-query-on-exit-flag df-process nil)
  (setq df-buf (get-buffer-create "xxxx"))
  (process-send-string df-process "1\n"))

(setq df-filter-lock nil)
(setq df-error nil)

(defun df-filter (p str)
  (unless df-error
    (with-current-buffer df-buf
      (insert (format "filter received %d bytes lock %s\n"
		      (length str) df-filter-lock)))
    (when df-filter-lock
      (setq df-error t)
      (error "recursive filter"))
    (setq df-filter-lock t)
    (setq long (make-string 4096 65))
    (process-send-string df-process long)
    (process-send-string df-process long)
    (process-send-string df-process long)
    (process-send-string df-process long)
    (process-send-string df-process long)
    (process-send-string df-process long)
    (process-send-string df-process long)
    (process-send-string df-process long)
    (setq df-filter-lock nil)))

(defun df-sentinel (p event)
  (setq df-error t)
  (with-current-buffer df-bug
    (insert "process died\n")))
==============================================================================
 



In GNU Emacs 23.4.1 (i486-pc-linux-gnu, GTK+ Version 2.24.10)
 of 2012-09-09 on murphy, modified by Debian
Windowing system distributor `The X.Org Foundation', version 11.0.11204000
configured using `configure  '--build' 'i486-linux-gnu' '--build' 'i486-linux-gnu' '--prefix=/usr' '--sharedstatedir=/var/lib' '--libexecdir=/usr/lib' '--localstatedir=/var/lib' '--infodir=/usr/share/info' '--mandir=/usr/share/man' '--with-pop=yes' '--enable-locallisppath=/etc/emacs23:/etc/emacs:/usr/local/share/emacs/23.4/site-lisp:/usr/local/share/emacs/site-lisp:/usr/share/emacs/23.4/site-lisp:/usr/share/emacs/site-lisp' '--with-crt-dir=/usr/lib/i386-linux-gnu' '--with-x=yes' '--with-x-toolkit=gtk' '--with-toolkit-scroll-bars' 'build_alias=i486-linux-gnu' 'CFLAGS=-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wall -DDEBIAN -O2' 'CPPFLAGS=-D_FORTIFY_SOURCE=2''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: Emacs-Lisp

Minor modes in effect:
  show-paren-mode: t
  msb-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t





Acknowledgement sent to Hendrik Tews <hendrik@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#13400; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.