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

[TESTBUG] serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java throws OutOfMemoryError

XMLWordPrintable

    • svc
    • 24
    • b07
    • generic
    • generic

        The second test in UnmountedVThreadNativeMethodAtTop.java implemented in UnmountedVThreadNativeMethodAtTop::VThreadBlockedAtOjectWait sometimes throws OOM.
        NB: without the fix for JDK-8361602 the OOM isn't reported. The test deadlocks until timeout instead.

        Analysis:

        * The first test case `VThreadBlockedAtSynchronizedNative` dumps the heap to a file and then parses it filling up the heap with objects representing the heap dump
        * The second test case `VThreadBlockedAtOjectWait` does the same.
        * Dumping and parsing is done in the same jvm process
        * The dump D2 of the second test case will contain live and also dead objects from the first test case if GC was not triggered. Among the dead objects will be many that represent the dump D1 from the first test case.
        * So D2 includes D1. D2 plus live objects for parsing can exceed the maximum heap size causing the OOM error.

        So in fact we are accumulating heap dumps on heap.
        This can be avoided by calling System.gc() before every test.

        Reproduce:

        * Duplicate the last test case UnmountedVThreadNativeMethodAtTop::VThreadBlockedAtOjectWait
           using the attached reproducer.patch
        * Running the tests with the following command will likely cause an OOM
           make test TEST=serviceability/HeapDump/UnmountedVThreadNativeMethodAtTop.java

        Stacktrace:

        java.lang.OutOfMemoryError: Java heap space
        at java.base/java.lang.Long.valueOf(Long.java:1000)
        at jdk.test.lib.hprof.model.Snapshot.makeId(Snapshot.java:590)
        at jdk.test.lib.hprof.model.Snapshot.findThing(Snapshot.java:366)
        at jdk.test.lib.hprof.model.JavaObjectArray.readValue(JavaObjectArray.java:157)
        at jdk.test.lib.hprof.model.JavaLazyReadObject.getValue(JavaLazyReadObject.java:79)
        at jdk.test.lib.hprof.model.JavaObjectArray.getElements(JavaObjectArray.java:87)
        at jdk.test.lib.hprof.model.JavaObjectArray.visitReferencedObjects(JavaObjectArray.java:103)
        at jdk.test.lib.hprof.model.Snapshot.calculateReferencesToObjects(Snapshot.java:324)
        at jdk.test.lib.hprof.model.Snapshot.resolve(Snapshot.java:292)
        at UnmountedVThreadNativeMethodAtTop.verifyHeapDump(UnmountedVThreadNativeMethodAtTop.java:132)
        at UnmountedVThreadNativeMethodAtTop.VThreadBlockedAtOjectWait(UnmountedVThreadNativeMethodAtTop.java:111)
        at java.base/java.lang.invoke.LambdaForm$DMH/0x000001000112c000.invokeVirtual(LambdaForm$DMH)

              rrich Richard Reingruber
              rrich Richard Reingruber
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: