JDK-8242165 : SA sysprops support fails to dump all system properties
  • Type: Bug
  • Component: hotspot
  • Sub-Component: svc-agent
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2020-04-05
  • Updated: 2020-04-15
  • Resolved: 2020-04-08
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 15
15 b18Fixed
Related Reports
Relates :  
Relates :  
Description
The following SA command can be used to print all system properties:

    jhsdb jinfo --sysprops --pid <pid>

The same can also be done using the clhsdb sysprops command. Both use SysPropsDumper to do the dumping, which relies on VM.getVM().getSystemProperties() to get the properties. The problem is some properties are missing from the output. This is easy to see if you compare the output to the Attach API version of jinfo, or jcmd:

    jinfo -sysprops <pid>
    jcmd <pid> VM.system_properties

The reason is because SA does not know how to properly iterate over the hashtable of entries. The entries are in an array, but each array entry can be chained if more than one property hashes to the same bucket. SA is not aware of this and does not walk down the chains.

Properties is a subclass of HashTable which has a ConcurrentHashMap to store the properties in. ConcurrentHashMap uses an array of Nodes, and it's these Nodes instances which can be chained. The fix is pretty simple:

--- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java
+++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/utilities/ObjectReader.java
@@ -205,6 +205,7 @@
       InstanceKlass ik = (InstanceKlass)oop.getKlass();
       OopField keyField = (OopField)ik.findField("key", "Ljava/lang/Object;");
       OopField valueField = (OopField)ik.findField("val", "Ljava/lang/Object;");
+      OopField nextField = (OopField)ik.findField("next", "Ljava/util/concurrent/ConcurrentHashMap$Node;");
 
       try {
          p.setProperty((String)readObject(keyField.getValue(oop)),
@@ -214,6 +215,11 @@
             debugPrintStackTrace(ce);
          }
       }
+      // If this hashmap table Node is chained, then follow the chain to the next Node.
+      Oop chainedOop = nextField.getValue(oop);
+      if (chainedOop != null) {
+          setPropertiesEntry(p, chainedOop);
+      }
    }

Comments
URL: https://hg.openjdk.java.net/jdk/jdk/rev/0337d3f76718 User: cjplummer Date: 2020-04-08 01:34:38 +0000
08-04-2020