Viewing 1 post (of 1 total)
  • Author
    Posts
  • #21074
    atnak
    Participant

    Settings are as follows:

    External Tool Properties:
    [x] Use Output Bar
    [x] Close on Exit

    Input
    [Document]
    [ ] Add EOF

    Output
    [Replace Document]
    Encoding: [System Default (932, shift_jis)
    Standard Error: [Display as Output Bar]

    Description of the problem:

    EmEditor hangs when running an External Tool that reads from stdin and writes to stdout, if the read and write are performed batches that exceed a certain number of bytes (4000~5000).

    Because the problem is hard to provide a minimalistic reproducible example for, I’m going to speculate on what’s going on.

    Speculation: The problem appears to occur if the External Tool writes, before reading from stdin, more bytes to stdout than EmEditor has allotted to the pipe buffer. It is likely the result of a deadlock that occurs because EmEditor is either blocked while waiting on the External Tool to finish, or blocked attempting to write to a full output pipe, without consuming the input pipe. (a.l.a. https://blogs.msdn.microsoft.com/oldnewthing/20110707-00/?p=10223)

    As it stands, the problem does not occur if the External Tool reads from and writes to stdin and stdout in smaller batches.

    Example:

    On my system, I can reproduce the problem if I create a document containing around 5000 characters then call the below (java) External Tool.

    public class InOut {
    	public static void main(String[] args) throws Exception {
    		for (int i = 0; i < 5000; i++) {
    			System.out.write('x');
    		}
    	}
    }

    When EmEditor hangs, the java program is stopped inside System.out.write().

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.