Uploaded image for project: 'Batik'
  1. Batik
  2. BATIK-1271

Thread-safety issue in AWTGlyphGeometryCache causing infinite loop

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.9
    • None
    • GVT
    • None

    Description

      Hello,

       

      Running Batik in a multi-threaded environment (JAVA EE application server), we are sometimes having threads stuck in infinite loop.

      Thread dump shows we are stucked in AWTGlyphGeometryCache.get() method.

      Heap dump shows we have an AWTGlyphGeometryCache$Entry instance that is referencing itself as ".next" item, resulting in an infinite loop when trying to run through the collection in AWTGlyphGeometryCache.get().

      Looking at the code, we found that the AWTGlyphGeometryCache.rehash() method is probably causing the problem : it is working on the 'table' class attribute and not on a copy. So if multiple threads enter this method concurrently, the following line may result in 'e.next = e' :

      e.next = table[index];

       

       

      Possible solutions that should work :

      1. make the method synchronized
      2. work on a local 'tmpTable', and assign it to the class attribute 'table' at the end of the method (cf suggested patch) 

       

       

      Attachments

        1. partial thread dump.txt
          3 kB
          Fabien Leroy
        2. heap dump.png
          25 kB
          Fabien Leroy
        3. AWTGlyphGeometryCache.diff
          0.5 kB
          Fabien Leroy

        Activity

          People

            Unassigned Unassigned
            lfabien Fabien Leroy
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: