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

Unsynchronized HashMap access causes endless loop

    XMLWordPrintable

Details

    • 2d
    • b45
    • x86
    • linux_suse_sles_11, solaris_10, windows_7
    • Verified

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "1.6.0_20"
        Java(TM) SE Runtime Environment (build 1.6.0_20-b02)
        Java HotSpot(TM) Server VM (build 16.3-b01, mixed mode)

        ADDITIONAL OS VERSION INFORMATION :
        Solaris 10 10/09 s10x_u8wos_08a X86
        SunOS 5.10 Generic_142901-06 i86pc i386 i86pc

        A DESCRIPTION OF THE PROBLEM :
        Using one of the polymorphic methods java.awt.Graphics2D.drawString() leads to an endless loop when accessing this method in a multi threaded environment. For example, we use a 3rd party library jcaptcha (http://jcaptcha.sourceforge.net/) to generate images within our web application.
        We discussed the problem and came to the conclusion, that not the implementation of the jcaptcha is the problem und must be implemented in a thread safe manner. Rather the implementation of the sdk code within sun.font.SunLayoutEngine.getEngine(LayoutEngineKey) should be thread safe. The read access to the hashmap is not synchronized and leads to endless loops for the threads which want to get the LayoutEngine. Unfortunatelly the thread which writes (hashmap.put()) has passed the code point and does not appear within our stack trace at all.

        java.lang.Thread.State: RUNNABLE
                at java.util.HashMap.get(HashMap.java:303)
                at sun.font.SunLayoutEngine.getEngine(SunLayoutEngine.java:115)
                at sun.font.GlyphLayout$EngineRecord.init(GlyphLayout.java:642)
                at sun.font.GlyphLayout.nextEngineRecord(GlyphLayout.java:494)
                at sun.font.GlyphLayout.layout(GlyphLayout.java:417)
                at sun.font.ExtendedTextSourceLabel.createGV(ExtendedTextSourceLabel.java:308)
                at sun.font.ExtendedTextSourceLabel.getGV(ExtendedTextSourceLabel.java:294)
                at sun.font.ExtendedTextSourceLabel.createLogicalBounds(ExtendedTextSourceLabel.java:208)
                at sun.font.ExtendedTextSourceLabel.getAdvance(ExtendedTextSourceLabel.java:117)
                at java.awt.font.TextLine.init(TextLine.java:264)
                at java.awt.font.TextLine.<init>(TextLine.java:110)
                at java.awt.font.TextLine.fastCreateTextLine(TextLine.java:952)
                at java.awt.font.TextLayout.fastInit(TextLayout.java:585)
                at java.awt.font.TextLayout.<init>(TextLayout.java:511)
                at sun.java2d.SunGraphics2D.drawString(SunGraphics2D.java:2804)
         

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        difficult to reproduce, but we think the code tells enough to tell you about the thread safety.


        REPRODUCIBILITY :
        This bug can be reproduced rarely.

        Attachments

          Issue Links

            Activity

              People

                prr Philip Race
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: