Bug 51917 - Race condition in PumpStreamHandler causes incorrect output from exec
Summary: Race condition in PumpStreamHandler causes incorrect output from exec
Status: NEEDINFO
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.8.2
Hardware: PC All
: P2 regression (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-29 13:59 UTC by Petar Petrov
Modified: 2011-12-06 16:50 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Petar Petrov 2011-09-29 13:59:36 UTC
There is a race condition in PumpStreamHandler. To reproduce execute a process using the ant API - the Execute class initialized with a LogStreamHandler instance. Put breakpoints at the beginning of PumpStreamHandler.stop() and LogOutputStream.processLine().

Make sure the process started with Execute.execute() outputs at least one line in the standard output and exits. Once you start debugging, the debugger will stop at both breakpoints - the process has exited and PumpStreamHandler.stop() is called, while the thread which handles the output has also stopped at the breakpoint in LogOutputStream.processLine(). At this point if you resume the first thread, flush() will be called on the output stream - this will call processLine(). Thus, two different threads will process the same line, duplicating it in the output.

We are working on a build tool in Eclipse which start an Ant build script and then parses the output. Because of this race condition we can't get a reliable output of a spawned process.

Also this problem is not present in Ant 1.7.1.
Comment 1 Stefan Bodewig 2011-12-06 16:50:24 UTC
since svn revision 1095736 flush() no longer calls processLine in order
to fix bug 50507

This should also fix the race condition you describe.  Can you please confirm
trunk works for you?