RFR: 8273152: Store base archive path in CDSFileMapHeaderBase [v2]

Ioi Lam iklam at openjdk.java.net
Wed Sep 22 19:44:59 UTC 2021


On Wed, 22 Sep 2021 03:51:19 GMT, Yumin Qi <minqi at openjdk.org> wrote:

>> Store base archive path offset in CDSFileMapHeaderBase (which should be invariant in evolving versions) so we can read the base archive name reliably from dynamic archive even with variant header sizes over versions.
>> 
>> tests: tier1-4
>> 
>> Thanks
>> Yumin
>
> Yumin Qi has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Fixed typo
>  - Moved _header_size from FileMapHeader to CDSFileMapHeaderBase and added tests

src/hotspot/share/cds/filemap.cpp line 1159:

> 1157:     }
> 1158:   }
> 1159: 

The check from 1144-1158 should be done inside `FileMapInfo::check_archive()`. This function  (`FileMapInfo::init_from_file`) is called *after* we have successfully loaded the header of an archive created by the current JDK. However, -- with JDK-8261455, we will need to read the headers of an archive created by a different JDK version, so we need to do the check at the very beginning, when we are examining the magic value, etc.

Also, the base archive's name should be considered as part of the header, so `header()->header_size()` should include the size of the base archive's name as well. Otherwise, we won't be able to read the entire header, including the base archive name, of an archive created by a different JDK version.

The check for header()->base_archive_path_offset() needs to be expanded:
- it must be smaller than header()->header_size()
- it must point to a valid 0-terminated string -- the string cannot run past the end of the header.

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

PR: https://git.openjdk.java.net/jdk/pull/5584


More information about the hotspot-runtime-dev mailing list