-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
JDK-8263467: Incorrect double-checked locking in sun.java2d.CRenderer #2948
Conversation
👋 Welcome back shade! A progress list of the required criteria for merging this PR into |
Webrevs
|
I guess "Incorrect double-checked" is a too strict description of this code, it just tried to eliminate the creation of one object and do not care about the content of that object, since it is immediately overridden. I think It will be more clear to just eliminate this DCL since overhead and code complexity seems too much to just cache five objects. Probably it was important in past(jdk6 and below) when this renderer was used for onscreen rendering. Currently, it is used for printing(if actually used at all). |
Ok, I removed the "DCL" from that code and used the objects directly. AFAICS, synchronization is redundant on those local objects. What would be a good test for this change? |
I guess that synchronization became redundant because the field was moved to the local var. But before that, it guarded the method in question for multithreaded access and that was not part of the DCL. So it will be better to return those fields back. As the test I have run all automated tests and some manual tests, none of them triggered this code. |
@shipilev 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! |
Not now, bot. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@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:
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 929 new commits pushed to the
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 |
Is not approved yet, see above. |
@shipilev 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! |
@shipilev This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the |
Seems this PR was lost for some reason. |
SonarCloud reports multiple incorrect double-checked locking cases in
sun.java2d.CRenderer
. For example:Arc2D
contains fields that are notfinal
.arcToShape
is notvolatile
. This makes it an incorrect DCL.This code is used by Mac OS, do it would probably blow up some time later on M1.
This is the candidate fix that preserves the semantics. I am doing this fix blindly so far, without testing on real Mac OS. But maybe there is no need to do any of this, because the setter methods overwrite the contents of all these objects under their own sync. So, maybe we can just allocate those objects without DCL-backed caching and pass them in?
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/2948/head:pull/2948
$ git checkout pull/2948
Update a local copy of the PR:
$ git checkout pull/2948
$ git pull https://git.openjdk.java.net/jdk pull/2948/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2948
View PR using the GUI difftool:
$ git pr show -t 2948
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/2948.diff