Skip to content

Unable to use jhsdb jmap to generate heap dump #97

@kzalewski11

Description

@kzalewski11

Describe the bug

Generating a heap dump with jhsdb jmap from either a live running JVM or from a core dump (generated using gdb) results in this error:

java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 10
        at jdk.hotspot.agent/sun.jvm.hotspot.utilities.GenericArray.getAddressAt(GenericArray.java:97)
        at jdk.hotspot.agent/sun.jvm.hotspot.utilities.MethodArray.at(MethodArray.java:61)
        at jdk.hotspot.agent/sun.jvm.hotspot.oops.ConstMethod.getMethod(ConstMethod.java:131)
        at jdk.hotspot.agent/sun.jvm.hotspot.oops.ConstMethod.isNative(ConstMethod.java:439)
        at jdk.hotspot.agent/sun.jvm.hotspot.oops.ConstMethod.getLineNumberFromBCI(ConstMethod.java:305)
        at jdk.hotspot.agent/sun.jvm.hotspot.oops.Method.getLineNumberFromBCI(Method.java:279)
        at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackFrame(HeapHprofBinWriter.java:867)
        at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackTraces(HeapHprofBinWriter.java:846)
        at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:460)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:216)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.run(JMap.java:103)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:278)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:241)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:134)
        at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.main(JMap.java:202)
        at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJMAP(SALauncher.java:340)
        at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:500)

This occurs both on our cloud instances and locally, and I suspect an issue with the jhsdb jmap tool. I have a colleague who has successfully run jmap commands successfully on the live JVM. Unfortunately this isn't a viable option for the OOM situation since the jmap option to run against a core dump file has been moved inside jhsdb.

To Reproduce

Directly from running JVM:
jhsdb jmap --pid <pid>
From core file:
jhsdb jmap --binaryheap --dumpfile <core_file> --exe <java_exe> --core <core_file>

Expected behavior

  1. Successful creation of heap dump from live JVM
  2. Successful generation of heap dump from core dump file

Platform information

OS: Ubuntu 24.04.2 LTS
Version Corretto-21.0.1.12.1

Additional context

We are currently starting our application with the JVM option -XX:+HeapDumpOnOutOfMemoryError. We've encountered a number of cases where the heap dump generation is taking much longer than expected, and has resulted in considerable downtime, sometimes around an hour or more for a ~6GB heap. As an attempt to work around this, I've been testing the option -XX:OnOutOfMemoryError to use gdb to take a core dump and subsequently parse out a heap dump from that, so we don't need to traverse the heap before restarting. This traversal is one of our suspects for why the heap dump is taking so long to generate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions