RFR: 8302777: CDS should not relocate heap if mapping fails

Calvin Cheung ccheung at openjdk.org
Fri Feb 17 18:25:22 UTC 2023


On Fri, 17 Feb 2023 17:15:04 GMT, Ioi Lam <iklam at openjdk.org> wrote:

> Please review this trivial fix: if the CDS archive heap is not available due to CRC errors, we shouldn't try to relocate its contents.
> 
> The bug was introduced in [JDK-8296158](https://bugs.openjdk.org/browse/JDK-8296158). Previously, if the CRC check fails, `MetaspaceShared::relocation_delta()` would be zero, so [`ArchiveHeapLoader::patch_native_pointers()`](https://github.com/openjdk/jdk/blob/a917fb3fcf0fe1a4c4de86c08ae4041462848b82/src/hotspot/share/cds/archiveHeapLoader.cpp#L535-L538) would return immediately. However, since [JDK-8296158](https://bugs.openjdk.org/browse/JDK-8296158), `MetaspaceShared::relocation_delta()` might be non-zero after CRC check has failed.
> 
> So the correct thing to do is to make sure the archive heap is available before doing anything with it.

Fix looks safe and trivial.

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

Marked as reviewed by ccheung (Reviewer).

PR: https://git.openjdk.org/jdk/pull/12622


More information about the hotspot-runtime-dev mailing list