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

Improve CDSHeapVerifier in handling of interned strings

XMLWordPrintable

    • b03

        If the archived heap object graphs points to any objects that may be reinitialized at run time, the JVM may behave incorrectly. CDSHeapVerifier tries to detect this kind of error. For an explanation, see

        https://github.com/openjdk/jdk/blob/3d9d353edb64dd364925481d7b7c8822beeaa117/src/hotspot/share/cds/cdsHeapVerifier.cpp#L40-L65

        However, cdsHeapVerifier's handling for interned strings is too strict for cases like this:

        ******
        At dumptime, FooBar is initialized, and its static field points to something like this:

            class FooBar {
                static final String xxx = System.getProperty("foo") == null ? "AAA" : "BBB"
            }

        The strings "AAA" and "BBB" are archived as part of the interned string table.

        None of the archived object graphs actually point to "AAA" or "BBB". (Note: the static fields of FooBar itself are not archived). So we don't have a condition that cdsHeapVerifier is trying to find.

        *******

        However, in this case, cdsHeapVerifier still reports an error, even

        [3.582s][warning][cds,heap] Field: FooBar::xxx
        [3.582s][warning][cds,heap] Value: java.lang.String
        [3.582s][warning][cds,heap] {0x000000060e8be8d0} - klass: 'java/lang/String'
        [3.582s][warning][cds,heap] - string: "AAA"
        [3.582s][warning][cds,heap] - ---- fields (total size 3 words):
        [3.582s][warning][cds,heap] - private 'hash' 'I' @12 0 (0x00000000)
        [3.582s][warning][cds,heap] - private final 'coder' 'B' @16 0 (0x00)
        [3.582s][warning][cds,heap] - private 'hashIsZero' 'Z' @17 true (0x01)
        [3.582s][warning][cds,heap] - injected 'flags' 'B' @18 1 (0x01)
        [3.582s][warning][cds,heap] - private final 'value' '[B' @20 [B{0x000000060e8be8e8} (0xc1d17d1d)
        [3.582s][warning][cds,heap] --- trace begin ---
        [3.582s][warning][cds,heap] [ 0] (shared string table)
        [3.582s][warning][cds,heap] [ 1] {0x000000060e8be8d0} java.lang.String
        [3.582s][warning][cds,heap] --- trace end ---

              iklam Ioi Lam
              iklam Ioi Lam
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: