Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-2503 MOP 2.0 design inflluencing issues
  3. GROOVY-5121

ClassInfo.modifiedExpandos is not thread safe, it can cause an infinite loop

    XMLWordPrintableJSON

Details

    • Sub-task
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.4, 2.0-beta-1
    • 2.4.0
    • groovy-runtime
    • None

    Description

      There is a thread safety problem in ClassInfo class. Concurrent access to ClassInfo.modifiedExpandos (used in ClassInfo.setStrongMetaClass / clearModifiedExpandos) can cause an infinite loop.

      Concurrent access to HashSet could cause an infinite loop when the tree data structure gets corrupted because of concurrent changes.
      (http://lightbody.net/blog/2005/07/hashmapget_can_cause_an_infini.html , HashSet uses HashMap under the covers)

      https://github.com/groovy/groovy-core/blob/GROOVY_1_8_X/src/main/org/codehaus/groovy/reflection/ClassInfo.java#L38

      private static final Set<ClassInfo> modifiedExpandos = new HashSet<ClassInfo>();
      

      modifiedExpandos seems to be used to maintain/clear strong references to EMCs? (ExpandoMetaClassCreationHandle.enable / disable calls ClassInfo.clearModifiedExpandos())

      discussion on mailing list about ClassInfo.modifiedExpandos (in another context):

      http://groovy.329449.n5.nabble.com/PermGen-leak-when-executing-many-scripts-via-GroovyShell-td3329653.html

      Attachments

        Activity

          People

            Unassigned Unassigned
            lhotari Lari Hotari
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: