8387684: [PrismFontFile] Possibly unsafe double check locking - #2205
8387684: [PrismFontFile] Possibly unsafe double check locking#2205andy-goryachev-oracle wants to merge 2 commits into
Conversation
|
👋 Welcome back angorya! A progress list of the required criteria for merging this PR into |
|
❗ This change is not yet ready to be integrated. |
|
The total number of required reviews for this PR has been set to 2 based on the presence of this label: |
Webrevs
|
| } | ||
|
|
||
| ColorGlyphStrike[] sbixStrikes = null; | ||
| private volatile ColorGlyphStrike[] sbixStrikes; |
There was a problem hiding this comment.
I don't have time to look at this for jfx27, so I recommend leaving it for after the fork, but I see at one other related threading issue. Both should be fixed at the same time (else there is little point in changing anything). The buildSbixStrikeTables() could be called twice, since it isn't inside the inner if (sbixStrikes == null). It won't be called concurrently, but will still do the initialization more than once which is, at best, unnecessary.
Minor: I prefer to leave the = null that you removed, since code is checking / relying on the initial value (yes I know it doesn't actually matter, but I find it more self-documenting with the explicit initialization).
There was a problem hiding this comment.
Good point, the whole thing is funky. I've restructured the code to make sure it is a proper double check locking and the buildSbixStrikeTables() is called only once.
For the null field, it's not necessary per JLS 4.12.5
https://docs.oracle.com/javase/specs/jls/se26/html/jls-4.html#jls-4.12.5 :
For all reference types (§4.3), the default value is null.
Besides, it annoys me when the debugger steps at each pointless assignments each time.
Fixes double check locking by adding the
volatilekeyword.During normal operation, the access seems to happen from two threads:
On one hand, this access is likely to be mutually exclusive, on the other hand, javafx does allow the nodes to be created in a background thread, and it might be possible to invoke, for example,
GlyphLayout.breakRuns()from a background thread.Progress
Issue
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/2205/head:pull/2205$ git checkout pull/2205Update a local copy of the PR:
$ git checkout pull/2205$ git pull https://git.openjdk.org/jfx.git pull/2205/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 2205View PR using the GUI difftool:
$ git pr show -t 2205Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/2205.diff
Using Webrev
Link to Webrev Comment