jdk icon indicating copy to clipboard operation
jdk copied to clipboard

6187113: DefaultListSelectionModel.removeIndexInterval(0, Integer.MAX_VALUE) fails

Open prsadhuk opened this issue 3 years ago • 5 comments

DefaultListSelectionModel.removeIndexInterva accepts int value which allows it to take in Integer.MAX_VALUE theoratically but it does calculation with that value which can results in IOOBE. Fix is to make sure the calculation stays within bounds.


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] Change requires a CSR request to be approved

Issues

  • JDK-6187113: DefaultListSelectionModel.removeIndexInterval(0, Integer.MAX_VALUE) fails
  • JDK-8295329: DefaultListSelectionModel.removeIndexInterval(0, Integer.MAX_VALUE) fails (CSR)

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10409/head:pull/10409
$ git checkout pull/10409

Update a local copy of the PR:
$ git checkout pull/10409
$ git pull https://git.openjdk.org/jdk pull/10409/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 10409

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10409.diff

prsadhuk avatar Sep 23 '22 13:09 prsadhuk

:wave: Welcome back psadhukhan! 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.

bridgekeeper[bot] avatar Sep 23 '22 13:09 bridgekeeper[bot]

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

  • client

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.

openjdk[bot] avatar Sep 23 '22 13:09 openjdk[bot]

CSR raised..https://bugs.openjdk.org/browse/JDK-8295329...please review

prsadhuk avatar Oct 14 '22 09:10 prsadhuk

There exists at least one other problem because of integer overflow in insertIndexInterval.

This code

        selectionModel.setSelectionInterval(Integer.MAX_VALUE - 1, Integer.MAX_VALUE);
        selectionModel.insertIndexInterval(Integer.MAX_VALUE - 1, Integer.MAX_VALUE, true);

throws

Exception in thread "main" java.lang.IndexOutOfBoundsException: bitIndex < 0: -2
	at java.base/java.util.BitSet.get(BitSet.java:626)
	at java.desktop/javax.swing.DefaultListSelectionModel.set(DefaultListSelectionModel.java:311)
	at java.desktop/javax.swing.DefaultListSelectionModel.setState(DefaultListSelectionModel.java:629)
	at java.desktop/javax.swing.DefaultListSelectionModel.insertIndexInterval(DefaultListSelectionModel.java:657)
	at SelectionModelTest.main(SelectionModelTest.java)

Would you like to include it as part of this fix? Shall I submit a new bug for this?

aivanov-jdk avatar Oct 14 '22 20:10 aivanov-jdk

Thanks for your suggestive code.. I guess you are now ok with handling Integer.MAX_VALUE in the code rather than only in javadoc.

BTW, your code change resulted in JCK failure so I have used a mix of what I had in previous iterations and your code and this satisfied JCK as well as the unit tests. Regarding insertIndexInterval I guess it's better to address in this PR as it has same issue in same file, so I have added a fix for it also in this PR.

prsadhuk avatar Oct 18 '22 04:10 prsadhuk

With the current code in the PR, six (6) test cases still fail.

The failure of test10 is expected: you adjust the value of length so that insMaxIndex can't be greater than Integer.MAX_VALUE. It is a valid failure, the test needs changing: lead should be become Integer.MAX_VALUE + 1 = -2147483648 (0x80000000).

Other five failures are valid ones, minIndex and maxIndex in the object don't have the expected values.

aivanov-jdk avatar Oct 26 '22 18:10 aivanov-jdk

/contributor add @aivanov-jdk

prsadhuk avatar Oct 28 '22 03:10 prsadhuk

I guess it's good idea to add your test into jtreg..

prsadhuk avatar Oct 28 '22 03:10 prsadhuk

@prsadhuk Contributor Alexey Ivanov <[email protected]> successfully added.

openjdk[bot] avatar Oct 28 '22 03:10 openjdk[bot]

CSR raised... https://bugs.openjdk.org/browse/JDK-8295329

prsadhuk avatar Oct 31 '22 08:10 prsadhuk

@prsadhuk This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Nov 29 '22 18:11 bridgekeeper[bot]

Let's keep it open. CSR review has stalled.

aivanov-jdk avatar Nov 29 '22 19:11 aivanov-jdk

@prsadhuk This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Dec 27 '22 19:12 bridgekeeper[bot]

The CSR was approved two days ago, yet the bots didn't update the status of the issue. It should be ready for integration.

aivanov-jdk avatar Jan 19 '23 19:01 aivanov-jdk

/label add csr

prsadhuk avatar Jan 30 '23 07:01 prsadhuk

@prsadhuk The label csr is not a valid label. These labels are valid:

  • serviceability
  • hotspot
  • hotspot-compiler
  • ide-support
  • kulla
  • i18n
  • shenandoah
  • jdk
  • javadoc
  • security
  • hotspot-runtime
  • jmx
  • build
  • nio
  • client
  • core-libs
  • compiler
  • net
  • hotspot-gc
  • hotspot-jfr

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]

/csr

prsadhuk avatar Jan 30 '23 07:01 prsadhuk

@prsadhuk an approved CSR request is already required for this pull request.

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]

/csr JDK-8295329

prsadhuk avatar Jan 30 '23 07:01 prsadhuk

@prsadhuk usage: /csr [needed|unneeded], requires that the issue the pull request refers to links to an approved CSR request.

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]

/csr unneeded

prsadhuk avatar Jan 30 '23 07:01 prsadhuk

@prsadhuk determined that a CSR request is not needed for this pull request.

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]

@prsadhuk 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:

6187113: DefaultListSelectionModel.removeIndexInterval(0, Integer.MAX_VALUE) fails

Co-authored-by: Alexey Ivanov <[email protected]>
Reviewed-by: aivanov

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]

/csr needed

prsadhuk avatar Jan 30 '23 07:01 prsadhuk

@prsadhuk has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@prsadhuk please create a CSR request for issue JDK-6187113 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]

/integrate

prsadhuk avatar Jan 30 '23 07:01 prsadhuk

Going to push as commit c2ebd179388cac5d6e10f98aab9a7ea909f8bc6b.

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]

@prsadhuk Pushed as commit c2ebd179388cac5d6e10f98aab9a7ea909f8bc6b.

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

openjdk[bot] avatar Jan 30 '23 07:01 openjdk[bot]