-
Bug
-
Resolution: Fixed
-
P2
-
6u23, 7
-
b126
-
x86
-
linux_redhat_5.0, windows_vista
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2213214 | 6u30 | David Buck | P2 | Closed | Fixed | b08 |
JDK-2213149 | 6u29-rev | David Buck | P2 | Resolved | Fixed | b20 |
JDK-2212237 | 6u27-rev | David Buck | P2 | Closed | Fixed | b21 |
JDK-2222024 | OpenJDK6 | David Buck | P5 | Resolved | Fixed | b25 |
FULL PRODUCT VERSION :
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux bud8 2.6.18-194.17.1.el5 #1 SMP Wed Sep 29 12:50:31 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If you use render text from multiple threads, you seem to be guaranteed to get a NullPointerException eventually.
Three other users report similar symptoms in comments at the end of bug 6359722, but that bug (a) appears to have originated as a different issue, and (b) is already closed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case. It may take some minutes, but will inevitably throw an NPE similar to the one below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at sun.font.FileFontStrike.getCachedGlyphPtr(FileFontStrike.java:470)
at sun.font.FileFontStrike.getSlot0GlyphImagePtrs(FileFontStrike.java:436)
at sun.font.CompositeStrike.getGlyphImagePtrs(CompositeStrike.java:97)
at sun.font.GlyphList.mapChars(GlyphList.java:254)
at sun.font.GlyphList.setFromString(GlyphList.java:226)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:53)
at sun.java2d.pipe.ValidatePipe.drawString(ValidatePipe.java:147)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2753)
at com.test.FileFontStrikeNPE.renderText(FileFontStrikeNPE.java:47)
at com.test.FileFontStrikeNPE.run(FileFontStrikeNPE.java:20)
at java.lang.Thread.run(Thread.java:662)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
public class FileFontStrikeNPE implements Runnable {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
new Thread(new FileFontStrikeNPE(), "Thread_" + i).start();
}
}
public void run() {
try {
renderText();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
private void renderText() {
BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = image.createGraphics();
int fontSize = (int) (Math.random() * 20) + 1;
graphics.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
graphics.translate(100, 100);
double rotation = 0.0;
String label = "Hello world!";
while (rotation < 100000) {
FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
int width = fontMetrics.stringWidth(label);
int y = fontMetrics.getAscent() / 2;
AffineTransform originalTransform = graphics.getTransform();
Shape originalClip = graphics.getClip();
graphics.rotate(rotation);
graphics.translate(-width / 2, y);
graphics.drawString(label, 0, 0);
graphics.setTransform(originalTransform);
graphics.setClip(originalClip);
rotation += 1.0;
}
}
}
---------- END SOURCE ----------
java version "1.6.0_23"
Java(TM) SE Runtime Environment (build 1.6.0_23-b05)
Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux bud8 2.6.18-194.17.1.el5 #1 SMP Wed Sep 29 12:50:31 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
If you use render text from multiple threads, you seem to be guaranteed to get a NullPointerException eventually.
Three other users report similar symptoms in comments at the end of bug 6359722, but that bug (a) appears to have originated as a different issue, and (b) is already closed.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the attached test case. It may take some minutes, but will inevitably throw an NPE similar to the one below.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
at sun.font.FileFontStrike.getCachedGlyphPtr(FileFontStrike.java:470)
at sun.font.FileFontStrike.getSlot0GlyphImagePtrs(FileFontStrike.java:436)
at sun.font.CompositeStrike.getGlyphImagePtrs(CompositeStrike.java:97)
at sun.font.GlyphList.mapChars(GlyphList.java:254)
at sun.font.GlyphList.setFromString(GlyphList.java:226)
at sun.java2d.pipe.GlyphListPipe.drawString(GlyphListPipe.java:53)
at sun.java2d.pipe.ValidatePipe.drawString(ValidatePipe.java:147)
at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2753)
at com.test.FileFontStrikeNPE.renderText(FileFontStrikeNPE.java:47)
at com.test.FileFontStrikeNPE.run(FileFontStrikeNPE.java:20)
at java.lang.Thread.run(Thread.java:662)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
public class FileFontStrikeNPE implements Runnable {
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
new Thread(new FileFontStrikeNPE(), "Thread_" + i).start();
}
}
public void run() {
try {
renderText();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
private void renderText() {
BufferedImage image = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);
Graphics2D graphics = image.createGraphics();
int fontSize = (int) (Math.random() * 20) + 1;
graphics.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, fontSize));
graphics.translate(100, 100);
double rotation = 0.0;
String label = "Hello world!";
while (rotation < 100000) {
FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
int width = fontMetrics.stringWidth(label);
int y = fontMetrics.getAscent() / 2;
AffineTransform originalTransform = graphics.getTransform();
Shape originalClip = graphics.getClip();
graphics.rotate(rotation);
graphics.translate(-width / 2, y);
graphics.drawString(label, 0, 0);
graphics.setTransform(originalTransform);
graphics.setClip(originalClip);
rotation += 1.0;
}
}
}
---------- END SOURCE ----------
- backported by
-
JDK-2213149 FileFontStrike appears not to be threadsafe?
- Resolved
-
JDK-2222024 FileFontStrike appears not to be threadsafe?
- Resolved
-
JDK-2212237 FileFontStrike appears not to be threadsafe?
- Closed
-
JDK-2213214 FileFontStrike appears not to be threadsafe?
- Closed
- duplicates
-
JDK-7011723 2D_Font/FontStyleTest threw Exception when display font name with isBold style in winVista
- Closed