Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8235300

VM_HeapDumper hits assert with bad dump_len

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P2 P2
    • openjdk8u252
    • hotspot
    • None
    • svc
    • behavioral
    • minimal
    • Hide
      Tools which depend on HRPOF format 1.0.1 will no longer work. But, all tools used with Java 8 support HPROF format 1.0.2, so we believe this change won't affect Java 8 users.

      The JVM parameter "SegmentedHeapDumpThreshold" is deprecated, but it's a develop flag, so is hidden from non-JVM-developer users.

      http://jperfanal.sourceforge.net/java.hprof.txt is a thread stack dump that references 1.0.1 and is dated Dec 30, 2001. The dump output is copyright 1998. So, 1.0.1 is probably from 1998.

      The file format spec at http://hg.openjdk.java.net/jdk6/jdk6/jdk/raw-file/tip/src/share/demo/jvmti/hprof/manual.html#mozTocId848088 is from Java 6, so 1.0.2 was supported then. Fixed in Java 6 were

      [JDK-6305542](https://bugs.openjdk.java.net/browse/JDK-6305542): HPROF binary format needs to support large dumps

      and

      [JDK-6313381](https://bugs.openjdk.java.net/browse/JDK-6313381): HPROF: agent should generate version 1.0.2 for large heaps

      which updated the hprof agent to generate 1.0.2 format files for heaps > 4gb.

      jmap support for 1.0.2 was added in 8u25 by

      [JDK-6313383](https://bugs.openjdk.java.net/browse/JDK-6313383): SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2"

      Conclusion: JDKs/JREs starting with Java 6 can read 1.0.2 files, and the SA can read them starting with 8u25.
      Show
      Tools which depend on HRPOF format 1.0.1 will no longer work. But, all tools used with Java 8 support HPROF format 1.0.2, so we believe this change won't affect Java 8 users. The JVM parameter "SegmentedHeapDumpThreshold" is deprecated, but it's a develop flag, so is hidden from non-JVM-developer users. http://jperfanal.sourceforge.net/java.hprof.txt is a thread stack dump that references 1.0.1 and is dated Dec 30, 2001. The dump output is copyright 1998. So, 1.0.1 is probably from 1998. The file format spec at http://hg.openjdk.java.net/jdk6/jdk6/jdk/raw-file/tip/src/share/demo/jvmti/hprof/manual.html#mozTocId848088 is from Java 6, so 1.0.2 was supported then. Fixed in Java 6 were [ JDK-6305542 ]( https://bugs.openjdk.java.net/browse/JDK-6305542): HPROF binary format needs to support large dumps and [ JDK-6313381 ]( https://bugs.openjdk.java.net/browse/JDK-6313381): HPROF: agent should generate version 1.0.2 for large heaps which updated the hprof agent to generate 1.0.2 format files for heaps > 4gb. jmap support for 1.0.2 was added in 8u25 by [ JDK-6313383 ]( https://bugs.openjdk.java.net/browse/JDK-6313383): SA: Update jmap to support HPROF binary format "JAVA PROFILE 1.0.2" Conclusion: JDKs/JREs starting with Java 6 can read 1.0.2 files, and the SA can read them starting with 8u25.
    • File or wire format
    • Implementation

      Summary

      When dumping the heap in binary format, always use HPROF format 1.0.2. Previously, format 1.0.1 was used for heaps smaller than 2GB.

      Problem

      public class BigArray {  
        public static void main(String[] args) throws Exception {  
      long[] b = new long[1024 * 1024 * 1024 / 2]; Object o = new Object(); synchronized(o) { o.wait(60000); } } }

      If you run the above code, and use "jmap" to generate a dump file, then use jhat to parse the dump file, you will get a warning message:

      "WARNING: Error reading heap dump or heap dump segment: Byte count is -4294967296 instead of 0"

      Eclipse MAT also can't parse the dump file correctly.

      Solution

      The root cause is that the length of the array exceeds the size of the u4 used to hold the heap dump segment length.

      The solution is to always use HPROF format 1.0.2's segmented dump format and to truncate to 2gb arrays that are larger than that.

      Webrev: http://cr.openjdk.java.net/~ddong/8144732/hotspot.02.

      Specification

      The HPROF heap dump file header always contains ""JAVA PROFILE 1.0.2" and never contains "JAVA PROFILE 1.0.1".

      The JVM parameter "SegmentedHeapDumpThreshold" is deprecated.

            phh Paul Hohensee
            jprovino Joseph Provino (Inactive)
            David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: