Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6979122

Endless loop while concurrently rendering text in multiple threads

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6
    • client-libs
    • 2d
    • x86
    • linux_suse_sles_11

      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 ----------

            srl Steven Loomis
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: