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
8286867: Update #getGlyphCode return a negative number #795
Conversation
When I used BlueJ, I found a problem with Chinese display. /javafx.graphics/com/sun/javafx/font/CompositeGlyphMapper.java#getGlyphCode may return a negative number when no font library is specified in Linux,and this could cause java.lang.ArrayIndexOutOfBoundsException error.So javafx.graphics/com/sun/prism/impl/GlyphCache.java#getCachedGlyph shou check the glyphCode.
Hi @Tomator01, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user Tomator01" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
The crash demo like this: public class MenuExample extends Application {
} |
@Tomator01 thank you for your interest in contributing to the OpenJFX project. In order for any comments that you add to this (or any other) PR to be retained, you will need to accept the OpenJDK Terms of Use as shown above. This is a one-time step. Please read the CONTRIBUTING guidelines, in particular the Before submitting a pull request section, for steps needed to advance this pull request, including:
|
I see that you already have submitted a bug report. You should get an email when it is made public. |
thanks,I'll wait for the bug |
/signed |
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
Hello,i have signed oca ,and pull /signed command ,so I'm just wait for OCA to pass? |
Reading the author's description of this PR, one wonders why the added condition is not "glyphCode < 0". if (glyphCode <= 0) {return null;} |
Your suggestion is right |
Yes, at this point you wait for your OCA to be processed. |
I can repeated this issue on uos when the linux doesn't have /usr/share/fonts/wps-office/FZSongS_20100603.TTF file ,openjfx version 11,method getGlyphCode will return a negative number |
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.
I left a question and style comment inline.
Can you provide an automated test case, or if that's not possible, a manual test case?
@@ -239,6 +239,8 @@ private void clearAll() { | |||
} | |||
|
|||
private GlyphData getCachedGlyph(int glyphCode, int subPixel) { | |||
if (glyphCode < 0) {return null;} |
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.
Have you ensured that all callers are prepared to deal with a null
return value?
Minor: Please format this according to code conventions:
if (glyphCode < 0) {
return null;
}
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.
`if (!packer.add(rect)) { if (PULSE_LOGGING_ENABLED) { PulseLogger.incrementCounter("Font Glyph Cache Cleared"); } // If add fails,clear up the cache. Try add again. clearAll(); if (!packer.add(rect)) { if (PrismSettings.verbose) { System.out.println(rect + " won't fit in GlyphCache"); } return null; } }
`
The line 298 also return null,so return nul is ok
@Tomator01 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! |
@Tomator01 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 |
When I used BlueJ, I found a problem with Chinese display. /javafx.graphics/com/sun/javafx/font/CompositeGlyphMapper.java#getGlyphCode may return a negative number when no font library is specified in Linux,and this could cause java.lang.ArrayIndexOutOfBoundsException error.So javafx.graphics/com/sun/prism/impl/GlyphCache.java#getCachedGlyph shou check the glyphCode.
The crash demo like this:
`import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class MenuExample extends Application {
public static void main(String[] args) {
launch(args);
}
} `
the error:
java.lang.ArrayIndexOutOfBoundsException: Index -25 out of bounds for length 32 at com.sun.prism.impl.GlyphCache.getCachedGlyph(GlyphCache.java:332) at com.sun.prism.impl.GlyphCache.render(GlyphCache.java:148) at com.sun.prism.impl.ps.BaseShaderGraphics.drawString(BaseShaderGraphics.java:2101) at com.sun.javafx.sg.prism.NGText.renderText(NGText.java:312) at com.sun.javafx.sg.prism.NGText.renderContent2D(NGText.java:270) at com.sun.javafx.sg.prism.NGShape.renderContent(NGShape.java:261) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:270) at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:578) at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:2072) at com.sun.javafx.sg.prism.NGNode.render(NGNode.java:1964) at com.sun.javafx.tk.quantum.ViewPainter.doPaint(ViewPainter.java:479) at com.sun.javafx.tk.quantum.ViewPainter.paintImpl(ViewPainter.java:328) at com.sun.javafx.tk.quantum.PresentingPainter.run(PresentingPainter.java:91)
Progress
Integration blocker
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/795/head:pull/795
$ git checkout pull/795
Update a local copy of the PR:
$ git checkout pull/795
$ git pull https://git.openjdk.org/jfx.git pull/795/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 795
View PR using the GUI difftool:
$ git pr show -t 795
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/795.diff
Webrev
Link to Webrev Comment