I'm working with JDI, and find out that call com.sun.jdi.VirtualMachine#dispose will hang at some situation.
The thread stack is :
"qtp1764345202-39" prio=5 tid=0x00007f830a14f000 nid=0x10d03 in Object.wait() [0x0000000128ea6000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x00000007039b1f40> (a com.sun.tools.jdi.Packet)
at java.lang.Object.wait(Object.java:503)
at com.sun.tools.jdi.TargetVM.waitForReply(TargetVM.java:300)
- locked <0x00000007039b1f40> (a com.sun.tools.jdi.Packet)
at com.sun.tools.jdi.VirtualMachineImpl.waitForTargetReply(VirtualMachineImpl.java:1036)
at com.sun.tools.jdi.PacketStream.waitForReply(PacketStream.java:69)
at com.sun.tools.jdi.JDWP$VirtualMachine$Dispose.waitForReply(JDWP.java:445)
at com.sun.tools.jdi.JDWP$VirtualMachine$Dispose.process(JDWP.java:431)
at com.sun.tools.jdi.VirtualMachineImpl.dispose(VirtualMachineImpl.java:555)
and from decompiled code, I saw this:
void waitForReply(Packet var1) {
synchronized(var1) {
while(!var1.replied && this.shouldListen) {
try {
var1.wait();
} catch (InterruptedException var5) {
;
}
}
if(!var1.replied) {
throw new VMDisconnectedException();
}
}
}
It's seem that there is a deadlock here, it's this a JDK bug? I'm using Hotspot JDK 7.
java version "1.7.0_79" Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)