Subject: Re: 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: Eli Zaretskii <[email-masked]>
Date: Mon, 11 Jan 2016 19:39:32 +0200

> Cc: [email-masked]
> From: Clément Pit--Claudel <[email-masked]>
> Date: Mon, 11 Jan 2016 11:40:11 -0500
> 
> > 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?

No, it's a native Windows port of 'cat' from GNU Coreutils.

> However I tried with Python, and indeed it didn't hang. It seems I oversimplified the example.

So what do the offending programs do differently?  Can you describe
what "jshint", whatever it is, does, it how it reads its stdin?  Does
it also write its stdout, btw?

> > 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.

Do you have experience with GDB?  Also, was the Emacs you have
compiled with debugging symbols?  if so, I can tell you where to look.

> * 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)))

What does jshint do with the stuff it reads from stdin?  Does it read
single bytes or larger chunks?