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

hprof heap dumps broken for lambda classdata

    XMLWordPrintable

Details

    • b151
    • x86_64
    • generic

    Backports

      Description

        FULL PRODUCT VERSION :
        $ java -version
        java version "1.8.0_60"
        Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
        Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        $ uname -a
        SunOS solaris 5.11 11.2 i86pc i386 i86pc

        $ uname -a
        Linux version 2.6.32-504.el6.x86_64

        64 Bit linux (No longer have access to machine)

        A DESCRIPTION OF THE PROBLEM :
        Here is a minimal test case running on Oracle Solaris:

        $ uname -a
        SunOS solaris 5.11 11.2 i86pc i386 i86pc
        $ java -version
        java version "1.8.0_60-ea"
        Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b25)
        Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
        $ cat LambdaSleep.java
        import java.util.Arrays;

        public class LambdaSleep {
            public static void main(String[] args) throws InterruptedException {
        String[] words = new String[] { "longer", "short" };
        Arrays.sort(words, (first, second) ->
        Integer.compare(first.length(), second.length()));
        Thread.sleep(300000);
            }
        }
        $ javac LambdaSleep.java
        $ java LambdaSleep &
        [1] 4528

        I took two hprof heap dumps of this program. The first, live4528.hprof, comes
        from the live process:

        $ jmap -dump:format=b,file=live4528.hprof 4528
        Dumping heap to /export/home/basil/live4528.hprof ...
        Heap dump file created

        The second, core4528.hprof, comes from a core dump:

        $ gcore 4528
        gcore: core.4528 dumped
        $ jmap -dump:format=b,file=core4528.hprof /opt/jdk/bin/java core.4528
        Attaching to core core.4528 from executable /opt/jdk/bin/java, please wait...
        Debugger attached successfully.
        Server compiler detected.
        JVM version is 25.60-b23
        Dumping heap to core4528.hprof ...
        Heap dump file created

        With the fix for JDK-8044416 in place, the heap dump is generated without any
        exceptions (which is an improvement), but it is still not usable in any
        meaningful way.

        While live4528.hprof loads in Eclipse MAT, core4528.hprof fails to load in
        Eclipse MAT with the following exception:

        !ENTRY org.eclipse.core.jobs 4 2 2015-08-06 08:32:45.883
        !MESSAGE An internal error occurred during: "Parsing heap dump from
        'core4528.hprof'".
        !STACK 0
        java.lang.NullPointerException
        at org.eclipse.mat.hprof.HprofParserHandlerImpl.resolveClassHierarchy(HprofParserHandlerImpl.java:587)
        at org.eclipse.mat.hprof.Pass2Parser.readInstanceDump(Pass2Parser.java:205)
        at org.eclipse.mat.hprof.Pass2Parser.readDumpSegments(Pass2Parser.java:159)
        at org.eclipse.mat.hprof.Pass2Parser.read(Pass2Parser.java:89)
        at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:94)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:222)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:126)
        at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:145)
        at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:83)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

        While both live4528.hprof and core4528.hprof load in VisualVM, attempting to
        find objects by retained size in VisualVM hangs on "Computing retained
        sizes..." for core4528.hprof, while this operation succeeds for
        live4528.hprof.

        When lambdas are not in use, the above problem is not manifest. Clearly there
        is a difference in the hprof heap dump generated from the core file compared
        to the one generated from the live process.

        This bug is also captured by Eclipse bug 476262 [1]. According to the comments
        on this bug, this error is reproducible on Windows (version unspecified).

        According to a stack overflow question [2], this bug has also been encountered
        on Linux version 2.6.32-504.el6.x86_64.

        [1] https://bugs.eclipse.org/bugs/show_bug.cgi?id=476262
        [2] https://stackoverflow.com/questions/34719148/mat-cant-open-the-dump-file

        REGRESSION. Last worked in version 7u76

        ADDITIONAL REGRESSION INFORMATION:
        $ /opt/jdk/bin/java -version
        java version "1.7.0_65"
        Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
        Java HotSpot(TM) Server VM (build 24.65-b04, mixed mode)

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Here is a minimal test case running on Oracle Solaris:

        $ uname -a
        SunOS solaris 5.11 11.2 i86pc i386 i86pc
        $ java -version
        java version "1.8.0_60-ea"
        Java(TM) SE Runtime Environment (build 1.8.0_60-ea-b25)
        Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
        $ cat LambdaSleep.java
        import java.util.Arrays;

        public class LambdaSleep {
            public static void main(String[] args) throws InterruptedException {
        String[] words = new String[] { "longer", "short" };
        Arrays.sort(words, (first, second) ->
        Integer.compare(first.length(), second.length()));
        Thread.sleep(300000);
            }
        }
        $ javac LambdaSleep.java
        $ java LambdaSleep &
        [1] 4528

        I took two hprof heap dumps of this program. The first, live4528.hprof, comes
        from the live process:

        $ jmap -dump:format=b,file=live4528.hprof 4528
        Dumping heap to /export/home/basil/live4528.hprof ...
        Heap dump file created

        The second, core4528.hprof, comes from a core dump:

        $ gcore 4528
        gcore: core.4528 dumped
        $ jmap -dump:format=b,file=core4528.hprof /opt/jdk/bin/java core.4528
        Attaching to core core.4528 from executable /opt/jdk/bin/java, please wait...
        Debugger attached successfully.
        Server compiler detected.
        JVM version is 25.60-b23
        Dumping heap to core4528.hprof ...
        Heap dump file created

        With the fix for JDK-8044416 in place, the heap dump is generated without any
        exceptions (which is an improvement), but it is still not usable in any
        meaningful way.

        While live4528.hprof loads in Eclipse MAT, core4528.hprof fails to load in
        Eclipse MAT with the following exception:

        !ENTRY org.eclipse.core.jobs 4 2 2015-08-06 08:32:45.883
        !MESSAGE An internal error occurred during: "Parsing heap dump from
        'core4528.hprof'".
        !STACK 0
        java.lang.NullPointerException
        at org.eclipse.mat.hprof.HprofParserHandlerImpl.resolveClassHierarchy(HprofParserHandlerImpl.java:587)
        at org.eclipse.mat.hprof.Pass2Parser.readInstanceDump(Pass2Parser.java:205)
        at org.eclipse.mat.hprof.Pass2Parser.readDumpSegments(Pass2Parser.java:159)
        at org.eclipse.mat.hprof.Pass2Parser.read(Pass2Parser.java:89)
        at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:94)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:222)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:126)
        at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:145)
        at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:83)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

        While both live4528.hprof and core4528.hprof load in VisualVM, attempting to
        find objects by retained size in VisualVM hangs on "Computing retained
        sizes..." for core4528.hprof, while this operation succeeds for
        live4528.hprof.

        When lambdas are not in use, the above problem is not manifest. Clearly there
        is a difference in the hprof heap dump generated from the core file compared
        to the one generated from the live process.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        The expected result is that an hprof generated from a core file of a Java 8 program utilizing lambdas would load in Eclipse MAT without throwing an exception. Additionally, VisualVM should be able to calculate the retained sizes for Java objects using the hprof.
        ACTUAL -
        The hprof of the given Java 8 program, generated from a
        core file, fails to load in Eclipse MAT with the following exception:

        !ENTRY org.eclipse.core.jobs 4 2 2015-08-06 08:32:45.883
        !MESSAGE An internal error occurred during: "Parsing heap dump from
        'core4528.hprof'".
        !STACK 0
        java.lang.NullPointerException
        at org.eclipse.mat.hprof.HprofParserHandlerImpl.resolveClassHierarchy(HprofParserHandlerImpl.java:587)
        at org.eclipse.mat.hprof.Pass2Parser.readInstanceDump(Pass2Parser.java:205)
        at org.eclipse.mat.hprof.Pass2Parser.readDumpSegments(Pass2Parser.java:159)
        at org.eclipse.mat.hprof.Pass2Parser.read(Pass2Parser.java:89)
        at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:94)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:222)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:126)
        at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:145)
        at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:83)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

        VisualVM hangs on "Computing retained sizes..."

        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        From Eclipse MAT:


        !ENTRY org.eclipse.core.jobs 4 2 2015-08-06 08:32:45.883
        !MESSAGE An internal error occurred during: "Parsing heap dump from
        'core4528.hprof'".
        !STACK 0
        java.lang.NullPointerException
        at org.eclipse.mat.hprof.HprofParserHandlerImpl.resolveClassHierarchy(HprofParserHandlerImpl.java:587)
        at org.eclipse.mat.hprof.Pass2Parser.readInstanceDump(Pass2Parser.java:205)
        at org.eclipse.mat.hprof.Pass2Parser.readDumpSegments(Pass2Parser.java:159)
        at org.eclipse.mat.hprof.Pass2Parser.read(Pass2Parser.java:89)
        at org.eclipse.mat.hprof.HprofIndexBuilder.fill(HprofIndexBuilder.java:94)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.parse(SnapshotFactoryImpl.java:222)
        at org.eclipse.mat.parser.internal.SnapshotFactoryImpl.openSnapshot(SnapshotFactoryImpl.java:126)
        at org.eclipse.mat.snapshot.SnapshotFactory.openSnapshot(SnapshotFactory.java:145)
        at org.eclipse.mat.ui.snapshot.ParseHeapDumpJob.run(ParseHeapDumpJob.java:83)
        at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        import java.util.Arrays;

        public class LambdaSleep {
            public static void main(String[] args) throws InterruptedException {
        String[] words = new String[] { "longer", "short" };
        Arrays.sort(words, (first, second) ->
        Integer.compare(first.length(), second.length()));
        Thread.sleep(300000);
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        There does not appear to be a workaround for this bug.

        Attachments

          1. dump1.txt
            9 kB
          2. dump2.txt
            9 kB
          3. jvisualvm_shot.png
            jvisualvm_shot.png
            96 kB

          Issue Links

            Activity

              People

                jgeorge Jini George (Inactive)
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: