unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: speech.free@gmail.com
To: help-gnu-emacs@gnu.org
Subject: Re: Emacs deadlocks on sub-process reads and writes
Date: Sat, 18 Oct 2014 23:38:15 -0700 (PDT)	[thread overview]
Message-ID: <cc505483-087e-413c-ba5f-a6b910d35cf3@googlegroups.com> (raw)
In-Reply-To: <2f4e5527-d9f0-4cfb-b20c-1b9dd110b7db@googlegroups.com>

I can now verify that by locking out the blocking write we no longer have the deadlock. So this would appear to be an Emacs bug or feature. I am using the Emacs 24.3.1 (i386-mingw-nt6.2.9200) of 2013-03-17 on MARVIN binary downloaded from Gnu site.

On Saturday, October 18, 2014 6:48:43 PM UTC-7, speec...@gmail.com wrote:
> I am debugging a Clang based code completer (irony-mode). Unfortunately the transfer between Emacs and the Clang sub-process is slow on Windows. We are experiencing frequent freeze-ups due to what looks like a deadlock. The deadlock happens under the following conditions:
> 
> 
> 
> 1. Emacs reading a large transfer from the sub-process (2+MB, around 2 seconds to finish on Windows after setting w32-pipe-read-delay to 0);
> 
> 
> 
> 2. While 1. is ongoing Emacs side send a new request to the sub-process. The request is regular source file sized -- it includes the buffer content being edited -- sufficient to cause a block on the write but nothing too big.
> 
> 
> 
> When these two conditions are met, Emacs UI reliably locks up until the sub-process is killed. The error message complaining about writing to a dead process after killing the sub-process shows that the Emacs was deadlocked waiting for the write to finish. The process buffer is half filled showing that the process filter function was no longer called. The write to the sub-process, which blocks the UI, can't proceed as it exceeds the size of the small write buffer. The sub-process will not read on its side until it finishes the transfer to Emacs. But for some reason Emacs also stopped reading from the pipe.
> 
> 
> 
> After poking around the Emacs code base a little bit it looks to me that when you call process-send-* in lisp Emacs eventually calls send_process in process.c. If the send can't complete it calls wait_reading_process_output, which calls read_and_dispose_of_process_output, which if there is new text received, calls the lisp process-filter. The logic in wait_reading_process_output is too complicated for me to understand if somehow it may decide not to call read_process_output, causing a deadlock. So I am asking for advice here.
> 
> 
> 
> A previous related question asked about transfer speed on Windows https://groups.google.com/forum/#!topic/gnu.emacs.help/Y0MYAz8WZUU I believe the slowness is the reason why this manifests itself on Windows but it may also appear on Linux under the right conditions. For a very long thread of discussion on this issue see https://github.com/Sarcasm/irony-mode/issues/131
> 
> 
> 
> Please feel free to forward to any Emacs list that may be relevant to solving this issue.


  reply	other threads:[~2014-10-19  6:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-19  1:48 Emacs deadlocks on sub-process reads and writes speech.free
2014-10-19  6:38 ` speech.free [this message]
2014-10-19 13:17   ` Eli Zaretskii
     [not found]   ` <mailman.11496.1413724706.1147.help-gnu-emacs@gnu.org>
2014-10-19 15:26     ` speech.free

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc505483-087e-413c-ba5f-a6b910d35cf3@googlegroups.com \
    --to=speech.free@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).