Reputation: 692
I run my application on linux, and sometimes it is hung.
please help me understand why it is hung. Please find callstack below. I supposed that something wrong with jvm.
user@ubuntu:~$ sudo /usr/lib/jvm/jdk1.7.0/bin/jstack -F 14429
Attaching to process ID 14429, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 23.25-b01
Deadlock Detection:
No deadlocks found.
Thread 14430: (state = BLOCKED)
Thread 14698: (state = IN_NATIVE)
- java.io.FileInputStream.readBytes(byte[], int, int) @bci=0 (Interpreted frame)
- java.io.FileInputStream.read(byte[], int, int) @bci=4, line=242 (Interpreted frame)
- java.io.BufferedInputStream.fill() @bci=175, line=235 (Interpreted frame)
- java.io.BufferedInputStream.read1(byte[], int, int) @bci=44, line=275 (Interpreted frame)
- java.io.BufferedInputStream.read(byte[], int, int) @bci=49, line=334 (Interpreted frame)
- java.io.FilterInputStream.read(byte[]) @bci=5, line=107 (Interpreted frame)
- org.apache.commons.exec.StreamPumper.run() @bci=31, line=105 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=724 (Interpreted frame)
Thread 14697: (state = IN_NATIVE)
- java.io.FileInputStream.readBytes(byte[], int, int) @bci=0 (Interpreted frame)
- java.io.FileInputStream.read(byte[], int, int) @bci=4, line=242 (Interpreted frame)
- java.io.BufferedInputStream.fill() @bci=175, line=235 (Interpreted frame)
- java.io.BufferedInputStream.read1(byte[], int, int) @bci=44, line=275 (Interpreted frame)
- java.io.BufferedInputStream.read(byte[], int, int) @bci=49, line=334 (Interpreted frame)
- java.io.FilterInputStream.read(byte[]) @bci=5, line=107 (Interpreted frame)
- org.apache.commons.exec.StreamPumper.run() @bci=31, line=105 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=724 (Interpreted frame)
Thread 14695: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=503 (Interpreted frame)
- java.lang.UNIXProcess.waitFor() @bci=8, line=210 (Interpreted frame)
- org.apache.commons.exec.DefaultExecutor.executeInternal(org.apache.commons.exec.CommandLine, java.util.Map, java.io.File, org.apache.commons.exec.ExecuteStreamHandler) @bci=106, line=347 (Interpreted frame)
- org.apache.commons.exec.DefaultExecutor.access$200(org.apache.commons.exec.DefaultExecutor, org.apache.commons.exec.CommandLine, java.util.Map, java.io.File, org.apache.commons.exec.ExecuteStreamHandler) @bci=6, line=46 (Interpreted frame)
- org.apache.commons.exec.DefaultExecutor$1.run() @bci=29, line=188 (Interpreted frame)
Thread 14621: (state = IN_NATIVE)
- java.lang.UNIXProcess.waitForProcessExit(int) @bci=0 (Interpreted frame)
- java.lang.UNIXProcess.access$200(java.lang.UNIXProcess, int) @bci=2, line=54 (Interpreted frame)
- java.lang.UNIXProcess$3.run() @bci=11, line=174 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1145 (Interpreted frame)
- java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=615 (Interpreted frame)
- java.lang.Thread.run() @bci=11, line=724 (Interpreted frame)
Thread 14496: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=503 (Interpreted frame)
- java.util.TimerThread.mainLoop() @bci=28, line=526 (Interpreted frame)
- java.util.TimerThread.run() @bci=1, line=505 (Interpreted frame)
Thread 14464: (state = BLOCKED)
Thread 14454: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove(long) @bci=44, line=135 (Interpreted frame)
- java.lang.ref.ReferenceQueue.remove() @bci=2, line=151 (Interpreted frame)
- java.lang.ref.Finalizer$FinalizerThread.run() @bci=16, line=189 (Interpreted frame)
Thread 14453: (state = BLOCKED)
- java.lang.Object.wait(long) @bci=0 (Interpreted frame)
- java.lang.Object.wait() @bci=2, line=503 (Interpreted frame)
- java.lang.ref.Reference$ReferenceHandler.run() @bci=46, line=133 (Interpreted frame)
Upvotes: 2
Views: 2342
Reputation: 572
As Peter Lawrey says, it seems that you are blocked in a waitFor() call in your code.
Maybe you are reading from process STDOUTPUT but not from STDERROR... Take a look at this ancient SO post Capturing stdout when calling Runtime.exec
EDIT: If you are using a ProcessBuilder in your code, try
yourProcessBuilder.redirectErrorStream(true);
Upvotes: 3