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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters #2279

Closed
wants to merge 3 commits into from

Conversation

amosshi
Copy link
Contributor

@amosshi amosshi commented Mar 8, 2024

Backport of JDK-8320570

  • NegativeSize.java - Clean backport
  • String.java - 3 sections change are unclean, the rest are clean. Details as bellow.
  • This PR contains 2 commits
    • The commit 1: is a clean backport part
    • The commit 2: is a manual fix of the following 3 sections,
      • Replace all new byte[length << 1] as StringUTF16.newBytesFor(length)
@@ -592,7 +592,7 @@
                     this.coder = LATIN1;
                     return;
                 }
-                byte[] utf16 = new byte[length << 1];
+                byte[] utf16 = StringUTF16.newBytesFor(length);
                 StringLatin1.inflate(latin1, 0, utf16, 0, dp);
                 dp = decodeUTF8_UTF16(latin1, sp, length, utf16, dp, true);
                 if (dp != length) {
@@ -601,7 +601,7 @@
                 this.value = utf16;
                 this.coder = UTF16;
             } else { // !COMPACT_STRINGS
-                byte[] dst = new byte[length << 1];
+                byte[] dst = StringUTF16.newBytesFor(length);
                 int dp = decodeUTF8_UTF16(bytes, offset, offset + length, dst, 0, true);
                 if (dp != length) {
                     dst = Arrays.copyOf(dst, dp << 1);
@@ -730,15 +730,15 @@
                 return new String(dst, LATIN1);
             }
             if (dp == 0) {
-                dst = new byte[length << 1];
+                dst = StringUTF16.newBytesFor(length);
             } else {
-                byte[] buf = new byte[length << 1];
+                byte[] buf = StringUTF16.newBytesFor(length);
                 StringLatin1.inflate(dst, 0, buf, 0, dp);
                 dst = buf;
             }
             dp = decodeUTF8_UTF16(bytes, offset, sl, dst, dp, false);
         } else { // !COMPACT_STRINGS
-            dst = new byte[length << 1];
+            dst = StringUTF16.newBytesFor(length);
             dp = decodeUTF8_UTF16(bytes, offset, offset + length, dst, 0, false);
         }
         if (dp != length) {
  • 馃挌 So this PR can be considered as semantics clean

Testing

  • Local:
    • Passed on MacOS M1 laptop
      • test/jdk/java/lang/String/CompactString/NegativeSize.java - Test results: passed: 1
    • Passed on Windows 11
      • test/jdk/java/lang/String/CompactString/NegativeSize.java - Test results: passed: 1
Processor	12th Gen Intel(R) Core(TM) i7-12800H   2.40 GHz
Installed RAM	64.0 GB (63.7 GB usable)
System type	64-bit operating system, x64-based processor

Edition: Windows 11 Enterprise
Version: 23H2
Installed on: 5/10/2023
OS build: 22631.3155
Experience: Windows Feature Experience Pack 1000.22684.1000.0
  • 鈿狅笍 Pipeline: Failed on linux-cross-compile / build (riscv64) only, not related to NegativeSize.java, should not caused by current PR
  • Testing Machine:
    • SAP nightlies passed on 2024-03-12 for commit 1,2 (on linuxppc64le, linuxx86_64, linuxaarch64)
    • SAP nightlies passed on 2024-03-15 for commit 3 (on NTAMD64|JTREG JDK (tier1))

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • JDK-8320570 needs maintainer approval

Issue

  • JDK-8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters (Bug - P3 - Approved)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk17u-dev.git pull/2279/head:pull/2279
$ git checkout pull/2279

Update a local copy of the PR:
$ git checkout pull/2279
$ git pull https://git.openjdk.org/jdk17u-dev.git pull/2279/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 2279

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk17u-dev/pull/2279.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 8, 2024

馃憢 Welcome back ashi! 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 changed the title Backport 82796bdebbf56b98ec97a6d572ed68c2842f60c6 8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters Mar 8, 2024
@openjdk
Copy link

openjdk bot commented Mar 8, 2024

This backport pull request has now been updated with issue from the original commit.

@openjdk openjdk bot added backport rfr Pull request is ready for review labels Mar 8, 2024
@mlbridge
Copy link

mlbridge bot commented Mar 8, 2024

Webrevs

@openjdk
Copy link

openjdk bot commented Mar 11, 2024

鈿狅笍 @amosshi This change is now ready for you to apply for maintainer approval. This can be done directly in each associated issue or by using the /approval command.

@phohensee
Copy link
Member

GHA failures appear to be infrastructure issues.

@openjdk
Copy link

openjdk bot commented Mar 13, 2024

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

8320570: NegativeArraySizeException decoding >1G UTF8 bytes with non-ascii characters

Reviewed-by: phh

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

  • fce02ad: 8326101: [PPC64] Need to bailout cleanly if creation of stubs fails when code cache is out of space
  • b0e3386: 8325326: [PPC64] Don't relocate in case of allocation failure
  • 373714b: 8322239: [macos] a11y : java.lang.NullPointerException is thrown when focus is moved on the JTabbedPane
  • 7d716fc: 8290901: Reduce use of -source in langtools tests
  • 807faa7: 8321489: Update LCMS to 2.16
  • dc60887: 8289401: Add dump output to TestRawRSACipher.java
  • 0499df3: 8285452: Add a new test library API to replace a file content using FileUtils.java
  • 4b9ab0d: 8286740: JFR: Active Setting event emitted incorrectly
  • c9b0307: 8268974: GetJREPath() JLI function fails to locate libjava.so if not standard Java launcher is used
  • 0b20589: 8324238: [macOS] java/awt/Frame/ShapeNotSetSometimes/ShapeNotSetSometimes.java fails with the shape has not been applied msg
  • ... and 19 more: https://git.openjdk.org/jdk17u-dev/compare/f221ff38300b5513a06e5755469668ef83556a3a...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 (@phohensee) 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).

@amosshi
Copy link
Contributor Author

amosshi commented Mar 15, 2024

/approval request "Backporting for parity with 17.0.12-oracle. Un-Clean backport. SAP nightlies passed on 2024-03-15鈥

@openjdk
Copy link

openjdk bot commented Mar 15, 2024

@amosshi
8320570: The approval request has been created successfully.

@openjdk openjdk bot added the approval label Mar 15, 2024
@openjdk openjdk bot added ready Pull request is ready to be integrated and removed approval labels Mar 19, 2024
@amosshi
Copy link
Contributor Author

amosshi commented Apr 9, 2024

/integrate

@openjdk
Copy link

openjdk bot commented Apr 9, 2024

Going to push as commit fc01ffe.
Since your change was applied there have been 103 commits pushed to the master branch:

  • c430b11: 8305645: System Tray icons get corrupted when Windows primary monitor changes
  • cb1a03c: 8325432: enhance assert message "relocation addr must be in this section"
  • 7217328: 8315652: RISC-V: Features string uses wrong separator for jtreg
  • 62e6dfa: 8313702: Update IANA Language Subtag Registry to Version 2023-08-02
  • 989e0bf: 8310818: Refactor more Locale tests to use JUnit
  • 533fac6: 8328638: Fallback option for POST-only OCSP requests
  • 31ba7e0: 8316462: sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java ignores VM flags
  • b96339f: 8308021: Update IANA Language Subtag Registry to Version 2023-05-11
  • 261e45a: 8306031: Update IANA Language Subtag Registry to Version 2023-04-13
  • 3764735: 8295026: Remove unused fields in StyleSheet
  • ... and 93 more: https://git.openjdk.org/jdk17u-dev/compare/f221ff38300b5513a06e5755469668ef83556a3a...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Apr 9, 2024
@openjdk openjdk bot closed this Apr 9, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Apr 9, 2024
@openjdk
Copy link

openjdk bot commented Apr 9, 2024

@amosshi Pushed as commit fc01ffe.

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

@amosshi amosshi deleted the backport-8320570 branch April 9, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport integrated Pull request has been integrated
2 participants