RFR: 8363986: Heap region in CDS archive is not at deterministic address

Ashutosh Mehra asmehra at openjdk.org
Wed Nov 5 22:58:01 UTC 2025


On Thu, 30 Oct 2025 05:46:49 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> **Overview**
> 
> This PR fixes the problem where the JDK build is not reproducible because the `lib/server/classes*.jsa` files do not always put the heap objects at the same addresses. This bug affects only `+UseCompressedOops`.
> 
> This bug is in generic code and is not specific to any platform. We hadn't hit this bug because our build platforms always allocated the heap at the same location. However, this is no longer true with macOS 26, which puts the heap at random locations.
> 
> **The fix**
> 
> (1) In `ArchiveHeapWriter::init()`, we check if we need deterministic heap contents.
> 
> (2) In `ArchiveHeapWriter::set_requested_address_range()`, if deterministic heap contents are needed, we always put the archived heap objects to just below `0x100000000`, so that we always write the archived oops into the CDS archive with  zero-based, zero-shift encoding.
> 
> Please see comments in the above two functions for more details.

src/hotspot/share/cds/archiveHeapWriter.cpp line 96:

> 94:     guarantee(MIN_GC_REGION_ALIGNMENT <= G1HeapRegion::min_region_size_in_words() * HeapWordSize, "must be");
> 95: 
> 96:     if (CDSConfig::old_cds_flags_used() && !CDSConfig::is_dumping_aot_linked_classes() && UseG1GC) {

Wouldn't it be better to add a VM command line flag to indicate that deterministic dump is needed, and use that flag in `Images.gmk`, instead of relying on these conditions?

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28052#discussion_r2496449963


More information about the hotspot-runtime-dev mailing list