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

Ioi Lam iklam at openjdk.org
Fri Feb 17 18:37:41 UTC 2023


On Fri, 17 Feb 2023 18:22:20 GMT, Calvin Cheung <ccheung 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, `FileMapRegion::mapped_base()` will be NULL for the heap regions, and thus we will skip the relocation in [`ArchiveHeapLoader::patch_native_pointers()`](https://github.com/openjdk/jdk/blob/a917fb3fcf0fe1a4c4de86c08ae4041462848b82/src/hotspot/share/cds/archiveHeapLoader.cpp#L535-L550).
>> 
>> However, since [JDK-8296158](https://bugs.openjdk.org/browse/JDK-8296158), `FileMapRegion::mapped_base()`  might be non-zero after CRC check has failed.
>> 
>> A proper fix is in [JDK-8302790](https://bugs.openjdk.org/browse/JDK-8302790) -- we should clear `FileMapRegion::mapped_base()`  when mapping fails.
>> 
>> However, that's a more involved fix and requires more testing. 
>> 
>> In the meantime, this PR will fix this crash. Also, it's a good idea to make sure the archive heap is available before doing anything with it.
>
> Fix looks safe and trivial.

Thanks @calvinccheung for the review.
The new code passes tier-4, where the crash was found.

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

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


More information about the hotspot-runtime-dev mailing list