Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8264413: Data is written to file header even if its CRC32 was calculated #3261

Closed

Conversation

@kelthuzadx
Copy link
Member

@kelthuzadx kelthuzadx commented Mar 30, 2021

Many tests under runtime/cds/appcds/dynamicArchive are crashed when turning on VerifySharedSpaces, VM reports inconsistent crc32 between dumptime and runtime(See detailed content on JBS attachments):

$ diff dump.log run.log
17c17
< - base_archive_is_default:        0
---
> - base_archive_is_default:        1
19c19
< - base_archive_name_size:         0
---
> - base_archive_name_size:         113

The root cause is that even if the CRC32 is calculated(Line 1902), ArchiveBuilder is still writing data to FileMapInfo(Line 1903):

mapinfo->set_requested_base((char*)MetaspaceShared::requested_base_address());
mapinfo->set_header_crc(mapinfo->compute_header_crc());
mapinfo->write_header();
mapinfo->close();

void FileMapInfo::write_header() {
_file_offset = 0;
seek_to_position(_file_offset);
char* base_archive_name = NULL;
if (header()->magic() == CDS_DYNAMIC_ARCHIVE_MAGIC) {
base_archive_name = (char*)Arguments::GetSharedArchivePath();
header()->set_base_archive_name_size(strlen(base_archive_name) + 1);
header()->set_base_archive_is_default(FLAG_IS_DEFAULT(SharedArchiveFile));
}
assert(is_file_position_aligned(), "must be");
write_bytes(header(), header()->header_size());
if (base_archive_name != NULL) {
write_bytes(base_archive_name, header()->base_archive_name_size());
}
}

Now the expected CRC32(serialized in CDS archive) is different from the calculated ones at runtime. This patch addresses this problem, it writes base_archive_name and size into header before calculating CRC32(if needed).

Thanks~
Yang


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8264413: Data is written to file header even if its CRC32 was calculated

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3261/head:pull/3261
$ git checkout pull/3261

Update a local copy of the PR:
$ git checkout pull/3261
$ git pull https://git.openjdk.java.net/jdk pull/3261/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3261

View PR using the GUI difftool:
$ git pr show -t 3261

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3261.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Mar 30, 2021

👋 Welcome back yyang! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr label Mar 30, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Mar 30, 2021

@kelthuzadx The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

@mlbridge mlbridge bot commented Mar 30, 2021

@kelthuzadx
Copy link
Member Author

@kelthuzadx kelthuzadx commented Mar 30, 2021

We can freeze(just like Metaspace::freeze) the FileMapInfo after CRC32 was calculated, any subsequent writing actions would be reported as illegal. Do you think this is worth doing? Looking forward to your comments.

@kelthuzadx kelthuzadx force-pushed the kelthuzadx:fix_dynamiccds_verifybug branch from c5a051a to 40b70a2 Mar 30, 2021
@kelthuzadx kelthuzadx force-pushed the kelthuzadx:fix_dynamiccds_verifybug branch from 40b70a2 to 4502220 Mar 30, 2021
Copy link
Member

@calvinccheung calvinccheung left a comment

Looks good.
I've tried your patch on linux-x64. It passed all cds tests and also in dynamic archive mode by specifying -vmoptions:'-Dtest.dynamic.cds.archive=true -XX:+VerifySharedSpaces' and test group <open repo>/test/hotspot/jtreg:hotspot_appcds_dynamic to the jtreg command line. It also passed the first 4 tiers of testing on Oracle supported platforms.
I've filed the following RFE for adding a test group for running CDS tests with -XX:+VerifySharedSpaces:
https://bugs.openjdk.java.net/browse/JDK-8264472

@openjdk
Copy link

@openjdk openjdk bot commented Mar 31, 2021

@kelthuzadx This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8264413: Data is written to file header even if its CRC32 was calculated

Reviewed-by: ccheung, minqi

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 35 new commits pushed to the master branch:

  • 52d8a22: 8264054: Bad XMM performance on java.lang.MathBench.sqrtDouble
  • 16acfaf: 8012229: [lcms] Improve performance of color conversion for images with alpha channel
  • cb70ab0: 8263235: sanity/client/SwingSet/src/ColorChooserDemoTest.java failed throwing java.lang.NoClassDefFoundError
  • e2ec997: 8263551: Provide shared lock-free FIFO queue implementation
  • dec3447: 8264346: nullptr_t undefined in global namespace for clang+libstdc++
  • 0fa3572: 8264489: Add more logging to LargeCopyWithMark.java
  • f43d14a: 8264396: Use the blessed modifier order in jdk.internal.jvmstat
  • 6225ae6: 8264466: Cut-paste error in InterfaceCalls JMH
  • 40c3249: 8264149: BreakpointInfo::set allocates metaspace object in VM thread
  • 999c134: 8264417: ParallelCompactData::region_offset should not accept pointers outside the current region
  • ... and 25 more: https://git.openjdk.java.net/jdk/compare/bcdf4694e07178de7d218f0dc21bda1c92e8f456...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@calvinccheung, @yminqi) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Mar 31, 2021
@kelthuzadx
Copy link
Member Author

@kelthuzadx kelthuzadx commented Mar 31, 2021

I've tried your patch on linux-x64. It passed all cds tests and also in dynamic archive mode by specifying -vmoptions:'-Dtest.dynamic.cds.archive=true -XX:+VerifySharedSpaces' and test group /test/hotspot/jtreg:hotspot_appcds_dynamic to the jtreg command line. It also passed the first 4 tiers of testing on Oracle supported platforms.

Besides, I've added a new dynamic cds test with -XX:+VerifySharedSpaces.

I've filed the following RFE for adding a test group for running CDS tests with -XX:+VerifySharedSpaces:
https://bugs.openjdk.java.net/browse/JDK-8264472

Looks good!

@yminqi
yminqi approved these changes Mar 31, 2021
Copy link
Contributor

@yminqi yminqi left a comment

LGTM.

@kelthuzadx
Copy link
Member Author

@kelthuzadx kelthuzadx commented Apr 1, 2021

Thanks @calvinccheung @yminqi for reviews.

/integrate

@openjdk openjdk bot added the sponsor label Apr 1, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 1, 2021

@kelthuzadx
Your change (at version c4b27fd) is now ready to be sponsored by a Committer.

@calvinccheung
Copy link
Member

@calvinccheung calvinccheung commented Apr 1, 2021

/sponsor

@openjdk openjdk bot closed this Apr 1, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Apr 1, 2021

@calvinccheung @kelthuzadx Since your change was applied there have been 35 commits pushed to the master branch:

  • 52d8a22: 8264054: Bad XMM performance on java.lang.MathBench.sqrtDouble
  • 16acfaf: 8012229: [lcms] Improve performance of color conversion for images with alpha channel
  • cb70ab0: 8263235: sanity/client/SwingSet/src/ColorChooserDemoTest.java failed throwing java.lang.NoClassDefFoundError
  • e2ec997: 8263551: Provide shared lock-free FIFO queue implementation
  • dec3447: 8264346: nullptr_t undefined in global namespace for clang+libstdc++
  • 0fa3572: 8264489: Add more logging to LargeCopyWithMark.java
  • f43d14a: 8264396: Use the blessed modifier order in jdk.internal.jvmstat
  • 6225ae6: 8264466: Cut-paste error in InterfaceCalls JMH
  • 40c3249: 8264149: BreakpointInfo::set allocates metaspace object in VM thread
  • 999c134: 8264417: ParallelCompactData::region_offset should not accept pointers outside the current region
  • ... and 25 more: https://git.openjdk.java.net/jdk/compare/bcdf4694e07178de7d218f0dc21bda1c92e8f456...master

Your commit was automatically rebased without conflicts.

Pushed as commit de495df.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@kelthuzadx kelthuzadx deleted the kelthuzadx:fix_dynamiccds_verifybug branch Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants