RFR: 8261455: Automatically generate the CDS archive if necessary [v2]
Ioi Lam
iklam at openjdk.java.net
Mon Jan 3 07:37:11 UTC 2022
On Mon, 27 Dec 2021 21:39:06 GMT, Yumin Qi <minqi at openjdk.org> wrote:
>> src/hotspot/share/cds/filemap.cpp line 207:
>>
>>> 205: if (!os::file_exists(_full_path)) {
>>> 206: return false;
>>> 207: }
>>
>> Is the above check necessary? If the file doesn't exist, will `check_archive()` below return false?
>
> It is needed here --- when open a file of name is NULL, os::open first does is checking:
> if (strlen(path) > MAX_PATH - 1) {
> errno = ENAMETOOLONG;
> return -1;
> }
> It will crash on NULL. Removing it will cause many tests fail. os:file_exists will first check if it is NULL.
> I will add comment for it.
I think we shouldn't be checking a FileMapInfo when its _file_path is NULL. I added the following assert:
bool FileMapInfo::validate_archive() const {
+ assert(_full_path != NULL, "huh");
if (!os::file_exists(_full_path)) {
return false;
}
and it crashes here (with dynamicArchive/HelloDynamic.java):
9 FileMapInfo::validate_archive
10 FileMapInfo::FileMapInfo
11 DynamicArchiveBuilder::init_header
12 DynamicArchiveBuilder::doit
13 VM_PopulateDynamicDumpSharedSpace::doit
14 VM_Operation::evaluate
15 VMThread::evaluate_operation
16 VMThread::inner_execute
17 VMThread::loop
...
At this point, we are writing the archive, so we shouldn't check the validity of the (output) archive, because we are going to overwrite it. And why is it NULL?
By the way, you added FileMapInfo::validate_archive() for doing this inside FileMapInfo::FileMapInfo():
bool valid = validate_archive();
if (!valid && !_is_static && AutoCreateSharedArchive) {
// regenerate shared archive at exit
DynamicDumpSharedSpaces = true;
ArchiveClassesAtExit = _full_path;
}
But the above block of code doesn't seem necessary, as it's already checked here inside FileMapInfo::initialize():
FileMapInfo::fail_continue("Initialize dynamic archive failed.");
if (AutoCreateSharedArchive) {
DynamicDumpSharedSpaces = true;
ArchiveClassesAtExit = Arguments::GetSharedDynamicArchivePath();
}
return false;
-------------
PR: https://git.openjdk.java.net/jdk/pull/6920
More information about the hotspot-runtime-dev
mailing list