Lucky-Dhakad / semanticvectors

Automatically exported from code.google.com/p/semanticvectors
Other
0 stars 1 forks source link

integration test spawned process can hang on I/O #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Running the integration test suite can cause the process spawned by 
Runtime.exec to hang when I/O overflows the tiny I/O buffers. I noticed the 
problem on Windows XP with the latest Sun/Oracle JVM.
Quoting from the Java API: "Because some native platforms only provide limited 
buffer size for standard input and output streams, failure to promptly write 
the input stream or read the output stream of the subprocess may cause the 
subprocess to block, and even deadlock."
See the Java API for process here: 
http://download.oracle.com/javase/6/docs/api/java/lang/Process.html

What is the expected output? What do you see instead?
When the spawned process fills the I/O buffers, the process will suspend until 
the caller drains the buffers. But RunTests doesn't ever drain the buffers, so 
the integration tests deadlock.

Please use labels and text to provide additional information.
The parent process will wait for the child to finish, the child will wait for 
the parent to drain the buffers, and the whole operation hangs.

I'll discuss solutions in the following reply.

Original issue reported on code.google.com by ThomasCR...@gmail.com on 22 Nov 2010 at 9:01

GoogleCodeExporter commented 9 years ago
RunTests.java line 126 and 131 are both examples of a spawned process that 
doesn't get its I/O drained.

I developing a fix that creates threads from the parent process to drain the 
buffers, and then outputs to the parent's STDOUT and STDERR either sequentially 
or as discovered. I'll write it to output as discovered unless told to do 
otherwise. This might interleave STDOUT and STDERR but will paint a better 
picture of runtime output.

The next question is where to put the fix. My current inclination is to add a 
method to the TestUtils class. The method would create the reader threads, 
spawn the child, attach the threads to the child, and wait for completion.

I'll attach a clean version of the fix for consideration sometime in the coming 
week.

Original comment by ThomasCR...@gmail.com on 22 Nov 2010 at 9:13

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've attached a new version of TestUtils.java. I'm going to think about this 
change for a while before I commit.

Example:
spawnChildProcess(IndexWriter.class, System.out, System.err);
// runs "java <all arguments passed to this jre> IndexWriter" and outputs to 
STDOUT and STDERR.

Original comment by ThomasCR...@gmail.com on 24 Nov 2010 at 11:04

Attachments:

GoogleCodeExporter commented 9 years ago
r401 has the fix for the child deadlock problem.

Original comment by ThomasCR...@gmail.com on 29 Nov 2010 at 5:20