-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8314236: Overflow in Collections.rotate #15270
Conversation
👋 Welcome back nikita-sakharin! A progress list of the required criteria for merging this PR into |
@nikita-sakharin The following label will be automatically applied to this pull request:
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. |
Submitted: JDK-8314236 Please change the PR synopsis to: "8314236: Overflow in Collections.rotate". Also go to https://github.com/nikita-sakharin/jdk/actions, and enable testing workflows. |
Webrevs
|
To avoid this situation, create a new branch for your changes and reset the
Then proceed to create a new pull request with |
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.
Superficially, this looks okay. Some OpenJDK code/test style trivia:
Thanks for the updates. With the "Mock List" implementation we can run the test in-JVM and we can avoid allocating several GB of memory. Great! The implementation logic in the Now that an individual test case is much less expensive, it becomes feasible to add multiple test cases. In particular, for this kind of testing of arithmetic errors, I like to test a variety of edge cases. The one test case you have is for size=
Please add these cases, and any others that you think might be interesting. |
@nikita-sakharin Please do not rebase or force-push to an active PR as it invalidates existing review comments. Note for future reference, the bots always squash all changes into a single commit automatically as part of the integration. See OpenJDK Developers’ Guide for more information. |
Thank you for your review! Tests were failing due to JDK-8313701. So I pulled changes from the I increased test coverage with respect to your request. All tests passed successfully. Awaiting the next step of your review. |
(The bot has already admonished you about avoiding rebasing. In practice merging works well and is helpful so that reviewers can see incremental changes.) The additional test cases look good. Sorry I forgot to mention this previously: it would be good to have a comment in the test that says that the test is only testing the index computations and not the actual rotation of elements. Meanwhile, I'll pull in the changes from your branch and run them through our internal build system, which is more reliable (and comprehensive) than GHA. |
Thank you for your review! I added comment for the test. |
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 update. Test run looks good! Approved.
@nikita-sakharin 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:
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 250 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. 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 (@shipilev, @stuart-marks) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
Stuart Marks has approved my changes. I am awaiting your feedback since you are reviewer for that PR too. Could I kindly ask you to review the PR, please? |
/integrate |
@nikita-sakharin Syntax:
User names can only be used for users in the census associated with this repository. For other contributors you need to supply the full name and email address. |
@nikita-sakharin |
/contributor add Nikita Sakharin 17588081+nikita-sakharin@users.noreply.github.com |
@nikita-sakharin |
Aleksey Shipilëv (@shipilev), kindly remind you about the PR. Could I ask you to review it, please? |
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.
OK, looks reasonable.
Aleksey Shipilëv (@shipilev), Stuart Marks (@stuart-marks), thank you for your approvals. Since both reviewers approved the PR, it is ready to be integrated. I have already executed |
I would like to push this early next week. |
/sponsor |
Going to push as commit 3828dc9.
Your commit was automatically rebased without conflicts. |
@shipilev @nikita-sakharin Pushed as commit 3828dc9. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
Collections.rotate
method contains a bug. This method throws IndexOutOfBoundsException on arrays larger thanOutput:
Exception in thread "main" java.lang.IndexOutOfBoundsException: Index -2147483648 out of bounds for length 1073741825
In that case private method
Collections.rotate1
will be called. And the line:i += distance;
will cause overflow. I fixed this method and wrote a test for it.
I've signed the Oracle Contributor Agreement, but I don't have permission to raise a bug in the JDK Bug System.
Kindly ask you to raise a bug.
Progress
Issue
Reviewers
Contributors
<17588081+nikita-sakharin@users.noreply.github.com>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15270/head:pull/15270
$ git checkout pull/15270
Update a local copy of the PR:
$ git checkout pull/15270
$ git pull https://git.openjdk.org/jdk.git pull/15270/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 15270
View PR using the GUI difftool:
$ git pr show -t 15270
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15270.diff
Webrev
Link to Webrev Comment