Subject: bug#22344: 25.0.50 (and 24.5.1, 24.4); Sending 4097 bytes to a subprocess hangs Emacs on Windows 8 and 10

From: Clément Pit--Claudel <[email-masked]>
Date: Mon, 11 Jan 2016 11:40:11 -0500

On 01/11/2016 10:37 AM, Eli Zaretskii wrote:
> If I modify your loop.cmd to have the following trivial command:
> 
>   @cat > foobar
>
> then Emacs doesn't hang, it happily writes those 4097 bytes, and after
> that, I see all of them in the 'foobar' file.  Moreover, I tried the
> same test with 100 times as many bytes (i.e. 409700), and it still
> worked as expected, with all of the bytes ending up in the file.

My Windows doesn't have cat; maybe you installed it through cygwin?
However I tried with Python, and indeed it didn't hang. It seems I oversimplified the example.

> So someone with access to the programs in question will have to step
> with a debugger through the code involved in this (I can point to the
> relevant parts of the Emacs C code), and find out what goes wrong
> there, and why. 

I don't think my Emacs experience on Windows is quite sufficient for that, but I would be happy ot help if you can guide me. Bear in mind that at the moment I don't even have a build chain set up for Emacs on Windows.

> Alternatively, if a reproducible test case can be
> posted with a simple program which reads its stdin and causes the
> hang, I will try debugging it myself.  (By "simple program" I meant
> something that won't involve installing lots of other packages,
> ideally something as simple as a batch file calling 'cat' or a similar
> program.)

Thanks for offering your help Eli. This is the simplest that I can get for now:

Assuming node.exe (installed using https://nodejs.org/dist/v4.2.4/node-v4.2.4-x64.msi) and jshint (installed using npm install --global jshint), here is a new recipe:

* This hangs:

(let ((process  (start-process "bug" nil "node" "c:/Users/cpitclaudel/AppData/Roaming/npm/node_modules/jshint/bin/jshint" "-")))
  (process-send-string process (make-string 4097 ?a)))

* This does not hang:

(let ((process  (start-process "bug" nil "node" "c:/Users/cpitclaudel/AppData/Roaming/npm/node_modules/jshint/bin/jshint" "-")))
  (dotimes (_ 25)
    (process-send-string process (make-string 4096 ?a))))

Cheers,
Clément.