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

SA sysprops support fails to dump all system properties

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 15
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b18

      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);
      + }
          }

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              cjplummer Chris Plummer
              Reporter:
              cjplummer Chris Plummer
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: