JDK-8225715 : jhsdb jmap fails to write binary heap dump of a jshell process
  • Type: Bug
  • Component: core-svc
  • Sub-Component: tools
  • Affected Version: 10,11.0.3,12,13
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: x86_64
  • Submitted: 2019-06-12
  • Updated: 2022-06-27
  • Resolved: 2019-07-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 13 JDK 14
11.0.5Fixed 13.0.4Fixed 14 b06Fixed
Related Reports
Relates :  
Relates :  
Description
ADDITIONAL SYSTEM INFORMATION :
Linux 5.0.0-16-generic #17-Ubuntu SMP Wed May 15 10:52:21 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

java version "11.0.3" 2019-04-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.3+12-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)


A DESCRIPTION OF THE PROBLEM :
Trying to dump a binary heap dump from a jshell process fails with NullPointerException

# jhsdb jmap --pid 9515 --binaryheap --dumpfile heap.hprof
Attaching to process ID 9515, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 11.0.3+12-LTS
Exception in thread "main" java.lang.NullPointerException
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeSymbolID(HeapHprofBinWriter.java:1121)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackFrame(HeapHprofBinWriter.java:752)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackTraces(HeapHprofBinWriter.java:725)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:434)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:182)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.run(JMap.java:97)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.main(JMap.java:176)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJMAP(SALauncher.java:326)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:455)
#

This looks similar to JDK-8213584

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
I used two terminals, one for jshell and another to run jhsdb jmap

First terminal, start a jshell process:
# jshell 
|  Welcome to JShell -- Version 11.0.3
|  For an introduction type: /help intro

jshell>

Second terminal, check pid of jshell and then run jshdb jmap:

# jcmd
9666 jdk.jcmd/sun.tools.jcmd.JCmd
9515 jdk.jshell/jdk.internal.jshell.tool.JShellToolProvider
9534 jdk.jshell.execution.RemoteExecutionControl 42871

# jhsdb jmap --pid 9515 --binaryheap --dumpfile heap.hprof
Attaching to process ID 9515, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 11.0.3+12-LTS
Exception in thread "main" java.lang.NullPointerException
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeSymbolID(HeapHprofBinWriter.java:1121)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackFrame(HeapHprofBinWriter.java:752)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackTraces(HeapHprofBinWriter.java:725)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:434)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:182)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.run(JMap.java:97)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.main(JMap.java:176)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJMAP(SALauncher.java:326)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:455)
#

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I expected the execution to finish with the message "heap written to heap.hprof"


ACTUAL -
Attaching to process ID 9515, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 11.0.3+12-LTS
Exception in thread "main" java.lang.NullPointerException
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeSymbolID(HeapHprofBinWriter.java:1121)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackFrame(HeapHprofBinWriter.java:752)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackTraces(HeapHprofBinWriter.java:725)
	at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:434)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:182)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.run(JMap.java:97)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:223)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118)
	at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.main(JMap.java:176)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJMAP(SALauncher.java:326)
	at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:455)

---------- BEGIN SOURCE ----------
jshell and jshdb are both included in the JDK
---------- END SOURCE ----------

FREQUENCY : always



Comments
Fix Request (13u) This fixes the corner case that makes diagnostics harder. Patch does apply to 13u cleanly
18-05-2020

This JShellHeapDumpTest.java test added by the fix for this CR fails in many different ways. One is clearly a test bug. See JDK-8228625. However, it also seems to uncover many different SA bugs if the jmap dump is done before jshell has reached the point of waiting for user input. See JDK-8230872.
26-09-2019

Fix Request (11u) This fixes the corner case that makes diagnostics harder. Patch does not apply to 11u cleanly, because the affected methods were changed by JDK 12, and patch requires simple adaptations. New test fails without product fix, passes with it. Patched build passes tier1. 11u RFR: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-August/001674.html
16-08-2019

URL: https://hg.openjdk.java.net/jdk/jdk/rev/f60890de1dfb User: kevinw Date: 2019-07-10 15:44:47 +0000
10-07-2019

This looks like regression from 10 ea b11 onwards, possibly due to JDK-6760477
25-06-2019

I am able to reproduce this issue on 11.0.3 with NPE, where as on 13 ea b24 it doesn't generate heapdump. Below is the output. 11.0.3 == -sh-4.1$ /scratch/fairoz/JAVA/jdk11/jdk-11.0.3_GA/bin/jhsdb jmap --pid 94637 --binaryheap --dumpfile heap.hprof Attaching to process ID 94637, please wait... Debugger attached successfully. Server compiler detected. JVM version is 11.0.3+12-LTS Exception in thread "main" java.lang.NullPointerException at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.writeSymbolID(HeapHprofBinWriter.java:1121) at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackFrame(HeapHprofBinWriter.java:752) at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.dumpStackTraces(HeapHprofBinWriter.java:725) at jdk.hotspot.agent/sun.jvm.hotspot.utilities.HeapHprofBinWriter.write(HeapHprofBinWriter.java:434) at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.writeHeapHprofBin(JMap.java:182) at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.run(JMap.java:97) at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.startInternal(Tool.java:260) at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.start(Tool.java:223) at jdk.hotspot.agent/sun.jvm.hotspot.tools.Tool.execute(Tool.java:118) at jdk.hotspot.agent/sun.jvm.hotspot.tools.JMap.main(JMap.java:176) at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.runJMAP(SALauncher.java:326) at jdk.hotspot.agent/sun.jvm.hotspot.SALauncher.main(SALauncher.java:455) 13 ea b24 == -sh-4.1$ /scratch/fairoz/JAVA/jdk13/jdk-13-ea+24/bin/jhsdb jmap --pid 95206 --binaryheap --dumpfile heap.hprof Attaching to process ID 95206, please wait... Debugger attached successfully. Server compiler detected. JVM version is 13-ea+24 null == Looks like duplicate of JDK-8213584 from JDK-8214156, But current test case doesn't have "-XX:StartFlightRecording=dumponexit=true," enabled, and it is easy to reproduce. I am keeping it separate as the original issue is not fixed yet.
13-06-2019