OpenJDK17 manual heap dump causes EAP to crash
Environment
- JBoss Enterprise Application Platform
- 7
- 8
- OpenJDK17
Issue
- When attempting to capture a heap dump (
/usr/lib/jvm/java-17/bin/jmap -dump:live,format=b,file=heapdump.hprof <APP_PID>),jmapfails with the following error:
Exception in thread "main" java.io.IOException: Premature EOF
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.readInt(HotSpotVirtualMachine.java:341)
at jdk.attach/sun.tools.attach.VirtualMachineImpl.execute(VirtualMachineImpl.java:197)
at jdk.attach/sun.tools.attach.HotSpotVirtualMachine.executeCommand(HotSpotVirtualMachine.java:310)
at jdk.jcmd/sun.tools.jmap.JMap.executeCommandForPid(JMap.java:133)
at jdk.jcmd/sun.tools.jmap.JMap.dump(JMap.java:248)
at jdk.jcmd/sun.tools.jmap.JMap.main(JMap.java:114)
- It causes the JBoss process to crash with the following in the fatal error log:
Current thread (0x000055dc0f466840): VMThread "VM Thread" [stack: 0x00007f951c826000,0x00007f951c926000] [id=2369242]
Stack: [0x00007f951c826000,0x00007f951c926000], sp=0x00007f951c924698, free space=1017k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.so+0x294324] AccessInternal::PostRuntimeDispatch<G1BarrierSet::AccessBarrier<548964ul, G1BarrierSet>, (AccessInternal::BarrierType)2, 548964ul>::oop_access_barrier(void*)+0x4
V [libjvm.so+0x7fb223] HeapRegion::object_iterate(ObjectClosure*)+0xc3
V [libjvm.so+0x71a06b] IterateObjectClosureRegionClosure::do_heap_region(HeapRegion*)+0x2b
V [libjvm.so+0x800fc0] HeapRegionManager::iterate(HeapRegionClosure*) const+0x40
V [libjvm.so+0x70d40e] G1CollectedHeap::object_iterate(ObjectClosure*)+0x3e
V [libjvm.so+0x7ed96e] VM_HeapDumper::work(unsigned int) [clone .part.156]+0x20e
V [libjvm.so+0xf7e3df] WorkGang::run_task(AbstractGangTask*, unsigned int, bool)+0xef
V [libjvm.so+0x7edf04] VM_HeapDumper::doit()+0x84
V [libjvm.so+0xf51f9f] VM_Operation::evaluate()+0xef
V [libjvm.so+0xf540c8] VMThread::inner_execute(VM_Operation*)+0x258
V [libjvm.so+0xf5453e] VMThread::loop()+0x12e
V [libjvm.so+0xf547dc] VMThread::run()+0x8c
V [libjvm.so+0xecf963] Thread::call_run()+0x73
V [libjvm.so+0xc3e18b] thread_native_entry(Thread*)+0xeb
Resolution
Remove -XX:-ClassUnloading to allow the default behavior of unloading unreachable classes to collect metaspace during garbage collection.
Root Cause
Class unloading is disabled with -XX:-ClassUnloading.
Diagnostic Steps
Check if the -XX:-ClassUnloadingJVM option is being used.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.