为什么试图依附自己撞毁我的虚拟机?

时间:2016-11-08 16:21:31

标签: java jvm jvm-hotspot jvm-crash

运行以下代码在macos上工作正常(sun jdk 1.8.0_51),但每次在centOS(sun jdk 1.8.0 101)上进行线程转储时都会崩溃,当它连接到自身时,同时成功连接任何其他可见的VM:

import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;

public class Test {

    public static void main(String[] args) throws Exception {
        for(VirtualMachineDescriptor vmd : VirtualMachine.list()) {
            VirtualMachine vm = VirtualMachine.attach(vmd);
        }
    }

}

线程转储:

"Service Thread" #8 daemon prio=9 os_prio=0 tid=0x00007fbb780bf000 nid=0x28a0 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C1 CompilerThread2" #7 daemon prio=9 os_prio=0 tid=0x00007fbb780bc000 nid=0x289f runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread1" #6 daemon prio=9 os_prio=0 tid=0x00007fbb780ba000 nid=0x289e runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"C2 CompilerThread0" #5 daemon prio=9 os_prio=0 tid=0x00007fbb780b7000 nid=0x289d runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" #4 daemon prio=9 os_prio=0 tid=0x00007fbb780b6000 nid=0x289c waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" #3 daemon prio=8 os_prio=0 tid=0x00007fbb78082800 nid=0x289b in Object.wait() [0x00007fbb62eed000]
   java.lang.Thread.State: WAITING (on object monitor)
               at java.lang.Object.wait(Native Method)
               - waiting on <0x00000000d6608ee0> (a java.lang.ref.ReferenceQueue$Lock)
               at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:143)
               - locked <0x00000000d6608ee0> (a java.lang.ref.ReferenceQueue$Lock)
               at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:164)
               at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:209)

"Reference Handler" #2 daemon prio=10 os_prio=0 tid=0x00007fbb7807e000 nid=0x289a in Object.wait() [0x00007fbb62fee000]
   java.lang.Thread.State: WAITING (on object monitor)
               at java.lang.Object.wait(Native Method)
               - waiting on <0x00000000d6606b50> (a java.lang.ref.Reference$Lock)
               at java.lang.Object.wait(Object.java:502)
               at java.lang.ref.Reference.tryHandlePending(Reference.java:191)
               - locked <0x00000000d6606b50> (a java.lang.ref.Reference$Lock)
               at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:153)

"main" #1 prio=5 os_prio=0 tid=0x00007fbb78008000 nid=0x2894 waiting on condition [0x00007fbb7f307000]
   java.lang.Thread.State: TIMED_WAITING (sleeping)
               at java.lang.Thread.sleep(Native Method)
               at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:100)
               at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)
               at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:250)
               at Test.main(Test.java:10)

"VM Thread" os_prio=0 tid=0x00007fbb78076800 nid=0x2899 runnable

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00007fbb7801d800 nid=0x2895 runnable

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00007fbb7801f800 nid=0x2896 runnable

"GC task thread#2 (ParallelGC)" os_prio=0 tid=0x00007fbb78021000 nid=0x2897 runnable

"GC task thread#3 (ParallelGC)" os_prio=0 tid=0x00007fbb78023000 nid=0x2898 runnable

"VM Periodic Task Thread" os_prio=0 tid=0x00007fbb780c2000 nid=0x28a1 waiting on condition

JNI global references: 19

Heap
PSYoungGen      total 37888K, used 9835K [0x00000000d6600000, 0x00000000d9000000, 0x0000000100000000)
  eden space 32768K, 30% used [0x00000000d6600000,0x00000000d6f9ad98,0x00000000d8600000)
  from space 5120K, 0% used [0x00000000d8b00000,0x00000000d8b00000,0x00000000d9000000)
  to   space 5120K, 0% used [0x00000000d8600000,0x00000000d8600000,0x00000000d8b00000)
ParOldGen       total 86016K, used 0K [0x0000000083200000, 0x0000000088600000, 0x00000000d6600000)
  object space 86016K, 0% used [0x0000000083200000,0x0000000083200000,0x0000000088600000)
Metaspace       used 3451K, capacity 4728K, committed 4864K, reserved 1056768K
  class space    used 382K, capacity 424K, committed 512K, reserved 1048576K

Exception in thread "main" com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: target process not responding or HotSpot VM not loaded
               at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:106)
               at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:78)
               at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:250)
               at Test.main(Test.java:10)
谁能解释一下吗?

0 个答案:

没有答案