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
8286978: SIGBUS in libz during CDS initialization #8799
8286978: SIGBUS in libz during CDS initialization #8799
Conversation
|
/label add hotspot-runtime |
@calvinccheung |
Webrevs
|
inputChannel.position(offset + nBytes); | ||
outputChannel.transferFrom(inputChannel, offset, orgSize - nBytes); | ||
long length = orgSize - nBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 458 doesn't seem to be needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line was removed in version v1 https://openjdk.github.io/cr/?repo=jdk&pr=8799&range=01#sdiff-0-test/lib/jdk/test/lib/cds/CDSArchiveUtils.java
// dstFile will keep original size so will remove corresponding bytes.length bytes at end of file | ||
public static File insertBytesRandomlyAfterHeader(File orgFile, String newFileName, byte[] bytes) throws Exception { | ||
long offset = fileHeaderSize(orgFile) + getRandomBetween(0L, 4096L); | ||
File dstFile = new File(newFileName); | ||
try (FileChannel inputChannel = new FileInputStream(orgFile).getChannel(); | ||
FileChannel outputChannel = new FileOutputStream(dstFile).getChannel()) { | ||
long orgSize = inputChannel.size(); | ||
outputChannel.transferFrom(inputChannel, 0, offset); | ||
transferFrom(inputChannel, outputChannel, 0, offset); | ||
outputChannel.position(offset); | ||
outputChannel.write(ByteBuffer.wrap(bytes)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes for transferFrom looks good, but we still have a problem with outputChannel.write(), which can also return fewer bytes than requested (or even zero).
For simplicity, I think it's best to ditch FileChannel and use FileOutputStream.write() instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option is to avoid using outputChannel.write(). Instead, duplicate some bytes from the end of the header.
public static File insertBytesRandomlyAfterHeader(File orgFile, String newFileName) throws Exception {
long headerSize = fileHeaderSize(orgFile);
long dupSize = getRandomBetween(0L, headerSize);
File dstFile = new File(newFileName);
try (FileChannel inputChannel = new FileInputStream(orgFile).getChannel();
FileChannel outputChannel = new FileOutputStream(dstFile).getChannel()) {
long orgSize = inputChannel.size();
// Copy the header
transferFrom(inputChannel, outputChannel, 0, headerSize);
// Copy dupSize bytes from the end of the header. Then, copy the rest
// of the input such that the new file will have the same size as
// the old file.
inputChannel.position(headerSize - dupSize);
transferFrom(inputChannel, outputChannel, headerSize, orgSize - headerSize);
}
return dstFile;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions. I've pushed another commit with the above changes. I also changed the callsite in SharedArchiveConsistency.java since there's no need to pass in a byte array.
@calvinccheung This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
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 16 new commits pushed to the
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.
|
Thanks @iklam for the review. |
Going to push as commit 087bccf.
Your commit was automatically rebased without conflicts. |
@calvinccheung Pushed as commit 087bccf. |
Please review this fix to ensure all requested bytes are transferred by calling
FileChannel.transferFrom
in a loop and checking its return value.Tested by running the SharedArchiveConsistency.java test on linux-aarch64 30 times on each of the following tier3 options:
-XX:+CreateCoredumpOnCrash -XX:+UseSerialGC
-XX:+CreateCoredumpOnCrash -XX:+UseParallelGC -XX:+UseNUMA
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8799/head:pull/8799
$ git checkout pull/8799
Update a local copy of the PR:
$ git checkout pull/8799
$ git pull https://git.openjdk.java.net/jdk pull/8799/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8799
View PR using the GUI difftool:
$ git pr show -t 8799
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8799.diff