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

8260934: java/lang/StringBuilder/HugeCapacity.java fails without Compact Strings #2355

Closed
wants to merge 4 commits into from

Conversation

@shipilev
Copy link
Contributor

@shipilev shipilev commented Feb 2, 2021

$ CONF=linux-x86_64-server-fastdebug make run-test TEST=java/lang/StringBuilder/HugeCapacity.java TEST_VM_OPTS=-XX:-CompactStrings

STDERR:
java.lang.OutOfMemoryError: Required length exceeds implementation limit
at java.base/java.lang.AbstractStringBuilder.newCapacity(AbstractStringBuilder.java:259)
at java.base/java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:229)
at java.base/java.lang.AbstractStringBuilder.ensureCapacity(AbstractStringBuilder.java:213)
at java.base/java.lang.StringBuilder.ensureCapacity(StringBuilder.java:87)
at HugeCapacity.testLatin1(HugeCapacity.java:49)
at HugeCapacity.main(HugeCapacity.java:37)

I went back and forth in fixing this test, and I think the best we can do is sense the current setting on CompactStrings and choose the test configuration based on that. The alternative is to use WhiteBox within the test (tried, it is quite a bit ugly). Note that this test deliberately does not run -XX:-CompactStrings even when vm.opt.final.CompactStrings returns true (= "available"), because that might mean TEST_VM_OPTS=-XX:+CompactStrings is in effect, and we have the VM option conflict.

Additional testing:

  • Linux x86_64, affected test (default), passes
  • Linux x86_64, affected test (-XX:-CompactStrings), passes
  • Linux x86_64, affected test (-XX:+CompactStrings), passes

Progress

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

Issue

  • JDK-8260934: java/lang/StringBuilder/HugeCapacity.java fails without Compact Strings

Reviewers

Download

$ git fetch https://git.openjdk.java.net/jdk pull/2355/head:pull/2355
$ git checkout pull/2355

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Feb 2, 2021

👋 Welcome back shade! 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.

@shipilev shipilev marked this pull request as ready for review Feb 2, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 2, 2021

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

  • core-libs

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 Feb 2, 2021

Webrevs

@shipilev
Copy link
Contributor Author

@shipilev shipilev commented Feb 9, 2021

Anyone? :)

@iklam
Copy link
Member

@iklam iklam commented Feb 9, 2021

Having two @test blocks makes the maintenance more difficult. I had to do a diff to find out the difference between the two blocks.

There's an existing test that explicitly tests both -XX:+CompactStrings and -XX:-CompactStrings. Maybe we can do the same thing?

* @run main/othervm -XX:+CompactStrings TestMethodNames

* @run main/othervm -Xms5G -Xmx5G -XX:+CompactStrings HugeCapacity true
* @run main/othervm -Xms5G -Xmx5G -XX:-CompactStrings HugeCapacity false

@shipilev
Copy link
Contributor Author

@shipilev shipilev commented Feb 9, 2021

Having two @test blocks makes the maintenance more difficult. I had to do a diff to find out the difference between the two blocks.

There's an existing test that explicitly tests both -XX:+CompactStrings and -XX:-CompactStrings. Maybe we can do the same thing?

No, I don't think we can. In other tests, the conflict between -XX:+CompactStrings and -XX:-CompactStrings would select one of the modes, so both test configurations would degenerate into one config (run twice). In this test, however, the compact strings mode defines whether the affected subtest would pass or fail, because it pokes at the allocation limit. So, we have to sense the actual setting of CompactStrings here.

As I said, the alternative would be sensing it programmatically via WhiteBox, at expense at single @test config, but with WhiteBox ceremony.

@iklam
Copy link
Member

@iklam iklam commented Feb 9, 2021

There's an existing test that explicitly tests both -XX:+CompactStrings and -XX:-CompactStrings. Maybe we can do the same thing?

No, I don't think we can. In other tests, the conflict between -XX:+CompactStrings and -XX:-CompactStrings would select one of the modes, so both test configurations would degenerate into one config (run twice).

I tried running jtreg -vmoptions:-XX:+CompactStrings TestMethodNames.java and the log file shows:

(the first @test)
-XX:+CompactStrings \
-XX:+CompactStrings \
com.sun.javatest.regtest.agent.MainWrapper /jdk2/tmp/jtreg/work/runtime/CompactStrings/TestMethodNames.d/main.0.jta

(the second @test)
-XX:+CompactStrings \
-XX:-CompactStrings \
com.sun.javatest.regtest.agent.MainWrapper /jdk2/tmp/jtreg/work/runtime/CompactStrings/TestMethodNames.d/main.1.jta

The VM options specified by the @test line are appended after the options specified by -vmoptions. So this test is executed in two different configurations (not twice in the same configuration).

@shipilev
Copy link
Contributor Author

@shipilev shipilev commented Feb 9, 2021

The VM options specified by the @test line are appended after the options specified by -vmoptions. So this test is executed in two different configurations (not twice in the same configuration).

Right, okay, so the last option wins, this is good. We can do what the updated version does. ...but then we also need to handle platforms where -XX:-CompactStrings is set by platform config (e.g. on ARM). -XX:+CompactStrings would be ignored there, and we cannot run test with true then. I think only ARM32 is affected, so it would be filtered by existing @requires, so it can be resolved later.

iklam
iklam approved these changes Feb 9, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 9, 2021

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

8260934: java/lang/StringBuilder/HugeCapacity.java fails without Compact Strings

Reviewed-by: iklam

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 15 new commits pushed to the master branch:

  • 05c6009: 8259656: fixpath.sh changes broke _NT_SYMBOL_PATH in RunTests.gmk
  • ef7ee3f: 8225081: Remove Telia Company CA certificate expiring in April 2021
  • 7c565f8: 8261209: isStandalone property: remove dependency on pretty-print
  • 01d9280: 8261299: Use-after-free on failure path in LinuxPackage.c, getJvmLauncherLibPath
  • a00b130: 8261356: Clean up enum G1Mark
  • becee64: 8261279: sun/util/resources/cldr/TimeZoneNamesTest.java timed out
  • f395ee0: 8261306: ServiceLoader documentation has malformed Unicode escape
  • 8f4c15f: 8198540: Dynalink leaks memory when generating type converters
  • edd5fc8: 8261096: Convert jlink tool to use Stream.toList()
  • 2f893c2: 8260337: Optimize ImageReader lookup, used by Class.getResource
  • ... and 5 more: https://git.openjdk.java.net/jdk/compare/5183d8ae1eec86202eace2c4770f81edbc73cb68...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.

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

@openjdk openjdk bot added the ready label Feb 9, 2021
@shipilev
Copy link
Contributor Author

@shipilev shipilev commented Feb 10, 2021

/integrate

@openjdk openjdk bot closed this Feb 10, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Feb 10, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 10, 2021

@shipilev Since your change was applied there have been 19 commits pushed to the master branch:

  • 752f92b: 6211242: AreaAveragingScaleFilter(int, int): IAE is not specified
  • 3af334a: 6211257: BasicStroke.createStrokedShape(Shape): NPE is not specified
  • 4619f37: 8261472: BasicConstraintsExtension::toString shows "PathLen:2147483647" if there is no pathLenConstraint
  • 699a3cd: 8223188: Removed unnecessary #ifdef __cplusplus from .cpp sources
  • 05c6009: 8259656: fixpath.sh changes broke _NT_SYMBOL_PATH in RunTests.gmk
  • ef7ee3f: 8225081: Remove Telia Company CA certificate expiring in April 2021
  • 7c565f8: 8261209: isStandalone property: remove dependency on pretty-print
  • 01d9280: 8261299: Use-after-free on failure path in LinuxPackage.c, getJvmLauncherLibPath
  • a00b130: 8261356: Clean up enum G1Mark
  • becee64: 8261279: sun/util/resources/cldr/TimeZoneNamesTest.java timed out
  • ... and 9 more: https://git.openjdk.java.net/jdk/compare/5183d8ae1eec86202eace2c4770f81edbc73cb68...master

Your commit was automatically rebased without conflicts.

Pushed as commit ad54d8d.

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

@shipilev shipilev deleted the JDK-8260934-hugecapacity-cs branch Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants