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

8260695: The java.awt.color.ICC_Profile#getData/getData(int) are not thread safe #2330

Closed
wants to merge 8 commits into from

Conversation

@mrserb
Copy link
Member

@mrserb mrserb commented Feb 1, 2021

Both methods are implemented in a similar way.

  1. Requests the size of the profile/tag data
  2. Creates an array of the correct size
  3. Requests the data and copy it to the array

If the data will be changed concurrently between steps 2. and 3. then we will get a mismatch between the array and copied data.

In the fix, all steps above are merged to just one step - return the data when requested.


Progress

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

Issue

  • JDK-8260695: The java.awt.color.ICC_Profile#getData/getData(int) are not thread safe

Reviewers

Download

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Feb 1, 2021

👋 Welcome back serb! 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
Copy link

@openjdk openjdk bot commented Feb 1, 2021

⚠️ @mrserb This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk
Copy link

@openjdk openjdk bot commented Feb 1, 2021

@mrserb The following labels will be automatically applied to this pull request:

  • 2d
  • awt

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added 2d awt labels Feb 1, 2021
mdl.getProfileData(cmmProfile, profileData);

return profileData;
return CMSManager.getModule().getProfileData(cmmProfile);
Copy link
Member Author

@mrserb mrserb Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one step, the array will be created in the native code under proper synchronization.

mdl.getTagData(p, tagSignature, tagData);
} catch(CMMException c) {
tagData = null;
return CMSManager.getModule().getTagData(p, tagSignature);
Copy link
Member Author

@mrserb mrserb Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one step, the array will be created in the native code under proper synchronization.

JNU_ThrowByName(env, "java/awt/color/CMMException",
"Insufficient buffer capacity.");
return;
jbyteArray data = (*env)->NewByteArray(env, pfSize);
Copy link
Member Author

@mrserb mrserb Feb 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we create the new array.

@mrserb mrserb marked this pull request as ready for review Feb 1, 2021
@openjdk openjdk bot added the rfr label Feb 1, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Feb 1, 2021

Webrevs

@mrserb
Copy link
Member Author

@mrserb mrserb commented Feb 6, 2021

/label remove awt

@openjdk openjdk bot removed the awt label Feb 6, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Feb 6, 2021

@mrserb
The awt label was successfully removed.

@@ -100,33 +100,19 @@ public Profile loadProfile(byte[] data) {
return p;
}

public int getProfileSize(Profile p) {
Copy link
Member

@azvegint azvegint Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it is a big loss, but it looks like we are no longer printing profile and tag sizes under CMMTracer after the fix.

@openjdk
Copy link

@openjdk openjdk bot commented Feb 7, 2021

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

8260695: The java.awt.color.ICC_Profile#getData/getData(int) are not thread safe

Reviewed-by: azvegint, 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 12 new commits pushed to the master branch:

  • 40ae993: 8261027: AArch64: Support for LSE atomics C++ HotSpot code
  • 9ffabf3: 8252971: WindowsFileAttributes does not know about Unix domain sockets
  • 682e78e: 8261071: AArch64: Refactor interpreter native wrappers
  • ebaa58d: 8261505: Test test/hotspot/jtreg/gc/parallel/TestDynShrinkHeap.java killed by Linux OOM Killer
  • 3210095: 8261079: Fix support for @hidden in classes and interfaces
  • 9c0ec8d: 8260941: Remove the conc_scan parameter for CardTable
  • da9895a: 8261499: Simplify HTML for javadoc links
  • 0779add: 8255059: Regressions >5% in all Javadoc benchmarks in 16-b19
  • 6a84ec6: 8260044: Parallel GC: Concurrent allocation after heap expansion may cause unnecessary full gc
  • 92ff891: 8261593: Do not use NULL pointer as write buffer parameter in jfrEmergencyDump.cpp write_repository_files
  • ... and 2 more: https://git.openjdk.java.net/jdk/compare/f4cfd758342a9afc8cc0fb2bb400ed8c791e0588...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 ready and removed ready labels Feb 7, 2021
@mrserb
Copy link
Member Author

@mrserb mrserb commented Feb 22, 2021

/integrate

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

@openjdk openjdk bot commented Feb 22, 2021

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

  • a30fb4f: 8255867: SignatureScheme JSSE property does not preserve ordering in handshake messages
  • a867288: 8211227: Inconsistent TLS protocol version in debug output
  • 7b924d8: 8261973: Shenandoah: Cleanup/simplify root verifier
  • 63f8fc8: 8259662: Don't wrap SocketExceptions into SSLExceptions in SSLSocketImpl
  • cf0019d: 8259942: Enable customizations in CompileJavaModules.gmk and Main.gmk
  • a6a7e43: 8242032: G1 region remembered sets may contain non-coarse level PRTs for already coarsened regions
  • d7eebda: 8261391: ZGC crash - SEGV in RevokeOneBias::do_thread
  • 5b7b18c: 8259800: timeout in tck test testForkJoin(ForkJoinPool8Test)
  • 419717d: 8261803: Remove unused TaskTerminator in g1 full gc ref proc executor
  • 011f5a5: 8261799: Remove unnecessary cast in psParallelCompact.hpp
  • ... and 122 more: https://git.openjdk.java.net/jdk/compare/f4cfd758342a9afc8cc0fb2bb400ed8c791e0588...master

Your commit was automatically rebased without conflicts.

Pushed as commit a7e2e80.

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

@mrserb mrserb deleted the JDK-8260695 branch Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants