United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-6979122 : Endless loop while concurrently rendering text in multiple threads

Details
Type:
Bug
Submit Date:
2010-08-23
Status:
Closed
Updated Date:
2012-06-11
Project Name:
JDK
Resolved Date:
2012-06-11
Component:
client-libs
OS:
linux_suse_sles_11
Sub-Component:
2d
CPU:
x86
Priority:
P4
Resolution:
Duplicate
Affected Versions:
6
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
FULL PRODUCT VERSION :


A DESCRIPTION OF THE PROBLEM :
Within method sun.font.SunLayoutEngine.getEngine() the field cacheref and the HashMap contained within are accessed without synchronisation.
Concurrent execution of methods calling sun.font.SunLayoutEngine.getEngine() leads to a corrupt HashMap and as a result in endless loops.
This is the case if TextLayout is used from mutliple threads concurrently. TextLayout subsequently calls SunLayoutEngine.getEngine():

	at sun.font.SunLayoutEngine.getEngine()
	at sun.font.GlyphLayout$EngineRecord.init()
	at sun.font.GlyphLayout.nextEngineRecord()
	at sun.font.GlyphLayout.layout()
	at sun.font.ExtendedTextSourceLabel.createGV()
	at sun.font.ExtendedTextSourceLabel.getGV()
	at sun.font.ExtendedTextSourceLabel.createLogicalBounds()
	at sun.font.ExtendedTextSourceLabel.getAdvance()
	at java.awt.font.TextLine.init()
	at java.awt.font.TextLine.()
	at java.awt.font.TextLine.fastCreateTextLine()
	at java.awt.font.TextLayout.fastInit()
	at java.awt.font.TextLayout.()


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
The bug is not reproducible all the time. The attached source code will at least cause sun.font.SunLayoutEngine.getEngine() to be called concurrently from multiple threads.


REPRODUCIBILITY :
This bug can be reproduced occasionally.

---------- BEGIN SOURCE ----------
import java.awt.Font;
import java.awt.font.FontRenderContext;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;


public class TextLayoutBug implements Runnable {
  public void run() {
    FontRenderContext FRC = new FontRenderContext(AffineTransform.getScaleInstance(1.0, 1.0), true, true);
    while (true) {
      Font f = new Font("Helvetica", Font.PLAIN, 16);
      new TextLayout("Test", f, FRC);
    }
  }
  
  public static void main(String[] args) {
    for (int i=0; i<2000; i++)
      new Thread(new TextLayoutBug()).start();
  }
}

---------- END SOURCE ----------

                                    

Comments



Hardware and Software, Engineered to Work Together