Bug 27614 - Ant hangs when running build with junit.
Summary: Ant hangs when running build with junit.
Status: RESOLVED WONTFIX
Alias: None
Product: Ant
Classification: Unclassified
Component: Optional Tasks (show other bugs)
Version: 1.6.1
Hardware: Sun Solaris
: P3 blocker with 1 vote (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-11 19:36 UTC by Henry Li
Modified: 2008-07-10 08:04 UTC (History)
2 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Henry Li 2004-03-11 19:36:17 UTC
Below is the full thread dump:

Full thread dump Java HotSpot(TM) Client VM (1.4.1_05-b01 mixed mode):

"Thread-8" daemon prio=5 tid=0xc89e8 nid=0x17 runnable [f1eff000..f1effc24]
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:174)
        at java.lang.UNIXProcess$DeferredCloseInputStream.read
(UNIXProcess.java:210)
        at org.apache.tools.ant.taskdefs.StreamPumper.run(StreamPumper.java:82)
        at java.lang.Thread.run(Thread.java:536)

"Thread-7" daemon prio=5 tid=0xc8850 nid=0x16 runnable [f1fff000..f1fffc24]
        at java.io.FileOutputStream.writeBytes(Native Method)
        at java.io.FileOutputStream.write(FileOutputStream.java:257)
        at java.io.PrintStream.write(PrintStream.java:258)
        - locked <f2f82fa0> (a java.io.PrintStream)
        at java.io.PrintStream.write(PrintStream.java:258)
        - locked <f2f199a8> (a java.io.PrintStream)
        at sun.nio.cs.StreamEncoder$CharsetSE.writeBytes(StreamEncoder.java:336)
        at sun.nio.cs.StreamEncoder$CharsetSE.implFlushBuffer
(StreamEncoder.java:404)
        at sun.nio.cs.StreamEncoder.flushBuffer(StreamEncoder.java:115)
        - locked <f2f23828> (a java.io.OutputStreamWriter)
        at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:169)
        at java.io.PrintStream.write(PrintStream.java:305)
        - locked <f2f199a8> (a java.io.PrintStream)
        at java.io.PrintStream.print(PrintStream.java:448)
        at java.io.PrintStream.println(PrintStream.java:585)
        - locked <f2f199a8> (a java.io.PrintStream)
        at org.apache.tools.ant.DefaultLogger.printMessage
(DefaultLogger.java:293)
        at org.apache.tools.ant.DefaultLogger.messageLogged
(DefaultLogger.java:259)
        at org.apache.tools.ant.Project.fireMessageLoggedEvent
(Project.java:1907)
        - locked <f2f82f18> (a org.apache.tools.ant.Project)
        at org.apache.tools.ant.Project.fireMessageLogged(Project.java:1956)
        at org.apache.tools.ant.Project.log(Project.java:396)
        at org.apache.tools.ant.Task.log(Task.java:347)
        at org.apache.tools.ant.taskdefs.LogOutputStream.processLine
(LogOutputStream.java:116)
        at org.apache.tools.ant.taskdefs.LogOutputStream.processLine
(LogOutputStream.java:107)
        at org.apache.tools.ant.taskdefs.LogOutputStream.processBuffer
(LogOutputStream.java:97)
        at org.apache.tools.ant.taskdefs.LogOutputStream.write
(LogOutputStream.java:77)
        at org.apache.tools.ant.taskdefs.LogOutputStream.write
(LogOutputStream.java:159)
        at org.apache.tools.ant.taskdefs.StreamPumper.run(StreamPumper.java:83)
        at java.lang.Thread.run(Thread.java:536)

"process reaper" daemon prio=5 tid=0xc7c48 nid=0x15 runnable 
[f1dff000..f1dffc24]
        at java.lang.UNIXProcess.waitForProcessExit(Native Method)
        at java.lang.UNIXProcess.access$1000(UNIXProcess.java:20)
        at java.lang.UNIXProcess$3.run(UNIXProcess.java:84)

"Signal Dispatcher" daemon prio=10 tid=0xb9bb0 nid=0x7 waiting on condition 
[0..0]

"Finalizer" daemon prio=8 tid=0xb60c0 nid=0x4 in Object.wait() 
[faaff000..faaffc24]
        at java.lang.Object.wait(Native Method)
        - waiting on <f2f82ea8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
        - locked <f2f82ea8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0xb47a0 nid=0x3 in Object.wait() 
[fcd7f000..fcd7fc24]
        at java.lang.Object.wait(Native Method)
        - waiting on <f2f82f10> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:426)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:113)
        - locked <f2f82f10> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x2d6b0 nid=0x1 in Object.wait() [ffbfd000..ffbfe7cc]
        at java.lang.Object.wait(Native Method)
        - waiting on <f3752858> (a java.lang.UNIXProcess)
        at java.lang.Object.wait(Object.java:426)
        at java.lang.UNIXProcess.waitFor(UNIXProcess.java:113)
        - locked <f3752858> (a java.lang.UNIXProcess)
        at org.apache.tools.ant.taskdefs.Execute.waitFor(Execute.java:532)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:481)
        at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked
(JUnitTask.java:778)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
(JUnitTask.java:629)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
(JUnitTask.java:600)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
        at org.apache.tools.ant.Main.runBuild(Main.java:632)
        at org.apache.tools.ant.Main.startAnt(Main.java:183)
        at org.apache.tools.ant.Main.start(Main.java:147)
        at org.apache.tools.ant.Main.main(Main.java:230)

"VM Thread" prio=5 tid=0xb3318 nid=0x2 runnable

"VM Periodic Task Thread" prio=10 tid=0xb8910 nid=0x5 waiting on condition
"Suspend Checker Thread" prio=10 tid=0xb9260 nid=0x6 runnable


This happens to Ant 1.5.4 also and the thread dump follows:

^\Full thread dump Java HotSpot(TM) Client VM (1.4.1_05-b01 mixed mode):

"Thread-7" daemon prio=5 tid=0x81ac00 nid=0x11 runnable [f1fff000..f1fffc24]
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:174)
        at java.lang.UNIXProcess$DeferredCloseInputStream.read
(UNIXProcess.java:210)
        at org.apache.tools.ant.taskdefs.StreamPumper.run(StreamPumper.java:105)
        at java.lang.Thread.run(Thread.java:536)

"Thread-6" daemon prio=5 tid=0x81aa68 nid=0x10 runnable [f1dff000..f1dffc24]
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:191)
        at java.lang.UNIXProcess$DeferredCloseInputStream.read
(UNIXProcess.java:219)
        at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
        - locked <f4055398> (a java.io.BufferedInputStream)
        at java.io.FilterInputStream.read(FilterInputStream.java:90)
        at org.apache.tools.ant.taskdefs.StreamPumper.run(StreamPumper.java:105)
        at java.lang.Thread.run(Thread.java:536)

"process reaper" daemon prio=5 tid=0x81a8d0 nid=0xf runnable 
[f1eff000..f1effc24]
        at java.lang.UNIXProcess.waitForProcessExit(Native Method)
        at java.lang.UNIXProcess.access$1000(UNIXProcess.java:20)
        at java.lang.UNIXProcess$3.run(UNIXProcess.java:84)

"Signal Dispatcher" daemon prio=10 tid=0xb9058 nid=0x7 waiting on condition 
[0..0]

"Finalizer" daemon prio=8 tid=0xb5568 nid=0x4 in Object.wait() 
[f2b7f000..f2b7fc24]
        at java.lang.Object.wait(Native Method)
        - waiting on <f3360cc0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
        - locked <f3360cc0> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0xb3c48 nid=0x3 in Object.wait() 
[facff000..facffc24]
        at java.lang.Object.wait(Native Method)
        - waiting on <f3360d28> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:426)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:113)
        - locked <f3360d28> (a java.lang.ref.Reference$Lock)

"main" prio=5 tid=0x2cb48 nid=0x1 in Object.wait() [ffbfe000..ffbfed94]
        at java.lang.Object.wait(Native Method)
        - waiting on <f40554b0> (a java.lang.UNIXProcess)
        at java.lang.Object.wait(Object.java:426)
        at java.lang.UNIXProcess.waitFor(UNIXProcess.java:113)
        - locked <f40554b0> (a java.lang.UNIXProcess)
        at org.apache.tools.ant.taskdefs.Execute.waitFor(Execute.java:466)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:448)
        at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.executeAsForked
(JUnitTask.java:685)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
(JUnitTask.java:559)
        at org.apache.tools.ant.taskdefs.optional.junit.JUnitTask.execute
(JUnitTask.java:532)
        at org.apache.tools.ant.Task.perform(Task.java:341)
        at org.apache.tools.ant.Target.execute(Target.java:309)
        at org.apache.tools.ant.Target.performTasks(Target.java:336)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1339)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1255)
        at org.apache.tools.ant.Main.runBuild(Main.java:609)
        at org.apache.tools.ant.Main.start(Main.java:196)
        at org.apache.tools.ant.Main.main(Main.java:235)

"VM Thread" prio=5 tid=0xb27b0 nid=0x2 runnable

"VM Periodic Task Thread" prio=10 tid=0xb7db8 nid=0x5 waiting on condition
"Suspend Checker Thread" prio=10 tid=0xb8708 nid=0x6 runnable
Comment 1 Henry Li 2004-03-11 20:01:35 UTC
With the Ant 1.5.4, it hangs sometime but passes sometime. With Ant 1.6.1 it 
hangs everytime so far. The same set of JUnit test cases ran without being hang 
if not ran under Ant.
Comment 2 Peter Reilly 2004-12-02 18:43:15 UTC
Can you provide an example build file that shows the problem?
Comment 3 Stefan Bodewig 2005-03-11 17:13:10 UTC
Does it hang if you don't fork <junit>?

Are you writing to System.out/.err in your tests or reading from System.in?
Comment 4 toby cabot 2006-10-12 13:32:40 UTC
I've got the same thing happening to me, but I'm using the <java> task instead
of <junit>.  If I fork="true" the child and run it in the background (in
GNU/Linux) then it blocks on a signal, and if I don't fork it it's fine.  If,
after it blocks, I bring it to the foreground, it will then proceed.

I worked around the problem by adding an input="/dev/null" attribute to the java
element, so it looks as if some code in junit depends on having stdin (even
though it doesn't appear to read from it).

Does anyone know how to get a thread dump of the child process?  If I redirect
the child's stdout and stderr to files and "kill -3" the child I don't get the
thread dump in either the out or err files.
Comment 5 Jesse Glick 2006-10-30 16:22:54 UTC
Anything involving <java> would be a separate bug. BTW to get a thread dump on
recent JDKs you can use jstack; find the right process using jps -lm.
Comment 6 Stefan Bodewig 2008-07-10 08:04:34 UTC
can't fix without more information