JDK-8323556 : CDS archive space addresses should be randomized with ArchiveRelocationMode=1
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 22,23
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: aarch64
  • Submitted: 2024-01-11
  • Updated: 2024-06-27
  • Resolved: 2024-01-19
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 22 JDK 23
22.0.1Fixed 23 b07Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
With JDK22 build 25: (expected behavior)
./jdk-22/fastdebug/bin/java -version
java version "22-ea" 2024-03-19
Java(TM) SE Runtime Environment (fastdebug build 22-ea+25-1998)
Java HotSpot(TM) 64-Bit Server VM (fastdebug build 22-ea+25-1998, mixed mode, sharing)
$ ./jdk-22/fastdebug/bin/java -Xlog:cds -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=1 --version | grep archive_space_rs | tail -1
[0.034s][info][cds] Reserved archive_space_rs [0x000002f000000000 - 0x000002f001000000] (16777216) bytes
$ ./jdk-22/fastdebug/bin/java -Xlog:cds -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=1 --version | grep archive_space_rs | tail -1
[0.031s][info][cds] Reserved archive_space_rs [0x000001c000000000 - 0x000001c001000000] (16777216) bytes
$ ./jdk-22/fastdebug/bin/java -Xlog:cds -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=1 --version | grep archive_space_rs | tail -1
[0.032s][info][cds] Reserved archive_space_rs [0x0000016000000000 - 0x0000016001000000] (16777216) bytes

With JDK22 build 26: (the archive address spaces are the same from run to run)
java version "22-ea" 2024-03-19
Java(TM) SE Runtime Environment (fastdebug build 22-ea+26-2112)
Java HotSpot(TM) 64-Bit Server VM (fastdebug build 22-ea+26-2112, mixed mode, sharing)
$ ./jdk-22/fastdebug/bin/java -Xlog:cds -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=1 --version | grep archive_space_rs | tail -1
[0.033s][info][cds] Reserved archive_space_rs [0x00007ff000000000 - 0x00007ff001000000] (16777216) bytes
$ ./jdk-22/fastdebug/bin/java -Xlog:cds -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=1 --version | grep archive_space_rs | tail -1
[0.032s][info][cds] Reserved archive_space_rs [0x00007ff000000000 - 0x00007ff001000000] (16777216) bytes
$ ./jdk-22/fastdebug/bin/java -Xlog:cds -XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=1 --version | grep archive_space_rs | tail -1
[0.032s][info][cds] Reserved archive_space_rs [0x00007ff000000000 - 0x00007ff001000000] (16777216) bytes

Bug only observed on the aarch64 platform.

(Note: in JDK22, the ArchiveRelocationMode is enabled by default. So the above results should be the same without the "-XX:+UnlockDiagnosticVMOptions -XX:ArchiveRelocationMode=1" VM options.)
Comments
Thanks for the spotting, [~stuefe]. I've raised https://bugs.openjdk.org/browse/JDK-8330001 to discuss the os::random issue.
10-04-2024

I don't think this is the right kind of fix. It is fine for this use case. But os::random should be, well, random. If it's not, that's a problem. It should not have to rely on callers using next_random with their own seeds. (I usually prefer next_random because it does not need to atomically access a global variable; still, os::random should work and be random). This also means that other uses of os::random suffer from the same problem. We should initialize the underlying seed to a semi-random value.
09-04-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk22/pull/98 Date: 2024-01-26 19:24:27 +0000
26-01-2024

Fix request for JDK 22 approved.
25-01-2024

Fix Request: This is a regression introduced in JDK 22 b26. This fix is simple and has gone through a round of CI testing in the mainline.
22-01-2024

Changeset: 437342b9 Author: Calvin Cheung <ccheung@openjdk.org> Date: 2024-01-19 17:11:01 +0000 URL: https://git.openjdk.org/jdk/commit/437342b93e9e66340ac57bd1c6fdc948b3302db0
19-01-2024

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/17409 Date: 2024-01-12 22:02:34 +0000
12-01-2024

This seems to be introduced by the fix for JDK-8320368.
11-01-2024