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

8271718: Crash when during color transformation the color profile is replaced #5042

Closed
wants to merge 1 commit into from

Conversation

@mrserb
Copy link
Member

@mrserb mrserb commented Aug 7, 2021

I have started the investigation of this code after this comment: #2957 (comment)

We have a suspicious synchronized keyword on the "setTagData" method. This method modified the data of the profile and invalidates the pointer to the native part of the profile. The usage of synchronized looks strange here since the code used by this method is thread-safe by itself.

I have double-checked the usage of the native pointers and found that a long time ago in jdk7 most of the methods in this class were synchronized and that prevents the usage of broken pointers, but unfortunately, the method "createTransform" added by the JDK-7043064 was not marked as such. So since then, it is possible to crash the "createTransform" by changing the content of the profile after "createTransform" save it locally and before it passes it to "the createNativeTransform".

There are three ways to fix the problem:

  1. Mark "createTransform" by the "synchronized" keyword. But it will prevent calling transformation by the different threads in parallel.
  2. Reimplement synchronization based on one static read/write lock, so modification of the profile could be possible by one thread at a time, while transformation could be done by a few threads. But the transformation will be blocked during some unused profiles(any profiles) modification.
  3. Reimplement synchronization based on read/write lock per profile. So if some unused profiles will be modified the transformation will work fine. But each transform operation will have to lock each needed profile before proceeding and the number of profiles could be some N.

I have selected the second solution based on the next assumption:
The profile modification operation is rare, and the transform operation is much more common. So in the worst case, this change adds one additional call to lock/unlock to the transform and does not affect the "setTagData"


Progress

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

Issue

  • JDK-8271718: Crash when during color transformation the color profile is replaced

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/5042/head:pull/5042
$ git checkout pull/5042

Update a local copy of the PR:
$ git checkout pull/5042
$ git pull https://git.openjdk.java.net/jdk pull/5042/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 5042

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/5042.diff

@mrserb mrserb changed the title JDK-8271718: Crash when during color transformation the color profile is replaced 8271718: Crash when during color transformation the color profile is replaced Aug 7, 2021
@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Aug 7, 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 openjdk bot changed the title 8271718: Crash when during color transformation the color profile is replaced 8271718: Crash when during color transformation the color profile is replaced Aug 7, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 7, 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 Aug 7, 2021
@mrserb
Copy link
Member Author

@mrserb mrserb commented Aug 7, 2021

/label remove awt

@openjdk openjdk bot removed the awt label Aug 7, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 7, 2021

@mrserb
The awt label was successfully removed.

getLcmsProfile(p).setTag(tagSignature, data);
} finally {
lock.unlockWrite(stamp);
}
Copy link
Member Author

@mrserb mrserb Aug 7, 2021

Choose a reason for hiding this comment

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

We have only one LCMS object at a time, so using "synchronized" and "writeLock" are kind of equivalent.

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

@mlbridge mlbridge bot commented Aug 7, 2021

Webrevs

prrace
prrace approved these changes Aug 9, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Aug 9, 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:

8271718: Crash when during color transformation the color profile is replaced

Reviewed-by: prr

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

  • 843943c: 8263567: gtests don't terminate the VM safely
  • 7fc99cf: 8225488: Examine ExecutableType.getReceiverType behavior when source receiver parameter is absent
  • 4548677: 8268824: Remove unused jdk.accessibility APIs deprecated for removal in JDK 9
  • b53828b: 8272047: java/nio/channels/FileChannel/Transfer2GPlus.java failed with Unexpected transfer size: 2147418112
  • 41dc795: 8264792: The NumberFormat for locale sq_XK formats price incorrectly.
  • 9c6457f: 8267385: Create NSAccessibilityElement implementation for JavaComponentAccessibility
  • 0ac2be9: 8272123: Problem list 4 jtreg tests which regularly fail on macos-aarch64
  • 272fcb4: 8272113: Build compare script fails with differences in classlist
  • 2f7a469: 8271931: Make AbortVMOnVMOperationTimeout more resilient to OS scheduling
  • a86ac0d: 8271939: Clean up primitive raw accessors in oopDesc
  • ... and 1 more: https://git.openjdk.java.net/jdk/compare/38ff85c824750e7da66fd86f5bde1c4587e529c4...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 Aug 9, 2021
@mrserb
Copy link
Member Author

@mrserb mrserb commented Aug 10, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Aug 10, 2021

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

  • 2a9acc3: 8272050: typo in MachSpillCopyNode::implementation after JDK-8131362
  • b62e742: 8213714: AttachingConnector/attach/attach001 failed due to "bind failed: Address already in use"
  • 66d1faa: 8271601: Math.floorMod(int, int) and Math.floorMod(long, long) differ in their logic
  • 57ae9fb: 8140442: Add getOutermostTypeElement to javax.lang.model utility class
  • 67869b4: 8270137: Kerberos Credential Retrieval from Cache not Working in Cross-Realm Setup
  • 35b399a: 8269130: Replace usages of Collection.toArray() with Collection.toArray(T[]) to avoid redundant array copying
  • 2b05fae: 8260262: Use common code in function unmap_shared() in perfMemory_posix.cpp
  • f2599ad: 8272196: Remove unused class ParStrongRootsScope
  • 1f88134: 8271869: AArch64: build errors with GCC11 in frame::saved_oop_result
  • 089e83b: 8266490: Extend the OSContainer API to support the pids controller of cgroups
  • ... and 17 more: https://git.openjdk.java.net/jdk/compare/38ff85c824750e7da66fd86f5bde1c4587e529c4...master

Your commit was automatically rebased without conflicts.

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

@openjdk openjdk bot commented Aug 10, 2021

@mrserb Pushed as commit 1489352.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants