CDS checks for file truncation with this in filemap.cpp:
if (is_static()) {
// just checking the last region is sufficient since the archive is written
// in sequential order
size_t len = os::lseek(fd, 0, SEEK_END);
FileMapRegion* si = space_at(MetaspaceShared::last_valid_region);
// The last space might be empty
if (si->file_offset() > len || len - si->file_offset() < si->used()) {
fail_continue("The shared archive file has been truncated.");
return false;
}
}
but when -XX:+UseSerialGC is used, the last_valid_region is empty so si->file_offset() == 0 and we didn't detect truncation. We should check all the regions instead. Also, this should be done for dynamic archive as well.
if (is_static()) {
// just checking the last region is sufficient since the archive is written
// in sequential order
size_t len = os::lseek(fd, 0, SEEK_END);
FileMapRegion* si = space_at(MetaspaceShared::last_valid_region);
// The last space might be empty
if (si->file_offset() > len || len - si->file_offset() < si->used()) {
fail_continue("The shared archive file has been truncated.");
return false;
}
}
but when -XX:+UseSerialGC is used, the last_valid_region is empty so si->file_offset() == 0 and we didn't detect truncation. We should check all the regions instead. Also, this should be done for dynamic archive as well.
- relates to
-
JDK-8286978 SIGBUS in libz during CDS initialization
-
- Resolved
-