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

-XX:+AutoCreateSharedArchive doesn't work when JDK build is switched

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 19
    • 19
    • hotspot
    • b26

      Expected: When you switch to a different JDK build, -XX:+AutoCreateSharedArchive should automatically update the specified dynamic CDS archive to match the new JDK.

      Actual: the new JDK fails to load the base archive, and thus is unable to generate the dynamic archive.

      =================================
      $ rm -f /tmp/foo.jsa
      $ /mybld/java/images/jdk/bin/java -Xlog:cds -Xlog:cds+map=debug:file=cds.map:none:filesize=0 -XX:+AutoCreateSharedArchive -cp ~/tmp/HelloWorld.jar -XX:SharedArchiveFile=/tmp/foo.jsa HelloWorld
      [0.001s][info][cds] UseSharedSpaces: Specified shared archive not found (/tmp/foo.jsa)
      [0.008s][info][cds] trying to map /mybld/java/images/jdk/lib/server/classes.jsa
      [0.008s][info][cds] Opened archive /mybld/java/images/jdk/lib/server/classes.jsa.
      [0.008s][info][cds] Archive was created with UseCompressedOops = 1, UseCompressedClassPointers = 1
      [0.008s][info][cds] Core region alignment: 4096
      [0.008s][info][cds] Reserved archive_space_rs [0x0000000800000000 - 0x0000000801000000] (16777216) bytes
      [0.008s][info][cds] Reserved class_space_rs [0x0000000801000000 - 0x0000000841000000] (1073741824) bytes
      [0.008s][info][cds] Mapped static region #0 at base 0x0000000800000000 top 0x000000080046f000 (ReadWrite)
      [0.008s][info][cds] Mapped static region #1 at base 0x000000080046f000 top 0x0000000800c42000 (ReadOnly)
      [0.008s][info][cds] CDS archive was created with max heap size = 128M, and the following configuration:
      [0.008s][info][cds] narrow_klass_base = 0x0000000800000000, narrow_klass_shift = 0
      [0.008s][info][cds] narrow_oop_mode = 0, narrow_oop_base = 0x0000000000000000, narrow_oop_shift = 0
      [0.008s][info][cds] heap range = [0x00000000f8000000 - 0x0000000100000000]
      [0.008s][info][cds] The current max heap size = 16088M, HeapRegion::GrainBytes = 8388608
      [0.008s][info][cds] narrow_klass_base = 0x0000000800000000, narrow_klass_shift = 0
      [0.008s][info][cds] narrow_oop_mode = 1, narrow_oop_base = 0x0000000000000000, narrow_oop_shift = 3
      [0.008s][info][cds] heap range = [0x0000000412800000 - 0x0000000800000000]
      [0.008s][info][cds] CDS heap data needs to be relocated because the archive was created with an incompatible oop encoding mode.
      [0.008s][info][cds] CDS heap data relocation delta = 30064771072 bytes
      [0.008s][info][cds] CDS heap data needs to be relocated lower by a further 7340032 bytes to 30057431040 to be aligned with HeapRegion::GrainBytes
      [0.008s][info][cds] Mapped static region #2 at base 0x00007f3a24080000 top 0x00007f3a240b9000 (Bitmap)
      [0.008s][info][cds] Trying to map heap data: region[3] at 0x00000007ff800000, size = 528384 bytes
      [0.008s][info][cds] Trying to map heap data: region[5] at 0x00000007ff700000, size = 487424 bytes
      [0.008s][info][cds] optimized module handling: enabled
      [0.008s][info][cds] full module graph: enabled
      [0.008s][info][cds] use_full_module_graph = true; java.base = 0x0000000800469208
      [0.008s][info][cds] patching heap embedded pointers
      [0.010s][info][cds] Unmapping region #2 at base 0x00007f3a24080000 (Bitmap)
      Hello World
      [0.042s][info][cds] Regenerate MethodHandle Holder classes...
      [.....]
      [0.176s][info][cds] Dumping shared data to file:
      [0.176s][info][cds] /tmp/foo.jsa
      [0.176s][info][cds] Shared file region (rw ) 0: 45936 bytes, addr 0x0000000800c42000 file offset 0x00001000 crc 0xabcded7d
      [0.176s][info][cds] Shared file region (ro ) 1: 57616 bytes, addr 0x0000000800c4e000 file offset 0x0000d000 crc 0xbc845f02
      [0.176s][info][cds] Shared file region (bm ) 2: 1672 bytes, addr 0x0000000000000000 file offset 0x0001c000 crc 0xa045a902

      $ /mybld/java-fastdebug/images/jdk/bin/java -Xlog:cds -XX:+AutoCreateSharedArchive -cp ~/tmp/HelloWorld.jar -XX:SharedArchiveFile=/tmp/foo.jsa HelloWorld
      [0.046s][info][cds] trying to map /mybld/java/images/jdk/lib/server/classes.jsa
      [0.046s][info][cds] Opened archive /mybld/java/images/jdk/lib/server/classes.jsa.
      [0.046s][info][cds] _jvm_ident expected: Java HotSpot(TM) 64-Bit Server VM (fastdebug 19-internal-adhoc.iklam.src) for linux-amd64 JRE (19-internal-adhoc.iklam.src), built on Jun 6 2022 20:46:08 by "iklam" with gcc 10.3.0
      [0.046s][info][cds] actual: Java HotSpot(TM) 64-Bit Server VM (19-internal-adhoc.iklam.src) for linux-amd64 JRE (19-internal-adhoc.iklam.src), built on Jun 6 2022 20:38:06 by "iklam" with gcc 10.3.0
      [0.046s][info][cds] UseSharedSpaces: The shared archive file was created by a different version or build of HotSpot
      [0.046s][info][cds] UseSharedSpaces: Initialize static archive failed.
      [0.046s][info][cds] UseSharedSpaces: Unable to map shared spaces
      Hello World

      =================================
      The problem is here:

      $ head -8 cds.map
      Dynamic CDS archive map for /tmp/foo.jsa
      [header 0x0000000000000000 - 0x00000000000003f8 1016 bytes]
      - magic: 0xf00baba8
      - crc: 0x0ac363f5
      - version: 14
      - header_size: 1016
      - base_archive_name_offset: 968
      - base_archive_name_size: 48

      According to https://github.com/openjdk/jdk/blob/master/src/hotspot/share/include/cds.h#L72

      base_archive_name_offset and base_archive_name_size should both be zero to indicate that /tmp/foo.jsa is generated using the default CDS archive.

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

              Created:
              Updated:
              Resolved: