Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4928

Deadlock on Closure creation

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Duplicate
    • 1.7.8
    • None
    • None
    • Linux RedHat 64-bit, JVM JRockit 1.6.0_22 (R28), Weblogic 10.3.3, Grails 1.3.7 with Groovy 1.7.8, production environment

    Description

      A deadlock has happened between two application server threads with the following stack trace:

      DEADLOCK DETECTED:
      ==================
      
      [deadlocked thread] [ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)':
      --------------------------------------------------------------------------------------------------
      Thread '[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'java.beans.PropertyDescriptor@1ac5f8c0' that is held by thread '[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)''
      
      Stack trace:
      ------------
      	java.beans.PropertyDescriptor.getReadMethod(PropertyDescriptor.java:158)
      	java.beans.Introspector.processPropertyDescriptors(Introspector.java:683)
      	java.beans.Introspector.getTargetPropertyInfo(Introspector.java:615)
      	java.beans.Introspector.getBeanInfo(Introspector.java:407)
      	java.beans.Introspector.getBeanInfo(Introspector.java:164)
      	groovy.lang.MetaClassImpl$15.run(MetaClassImpl.java:2940)
      	groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:2938)
      	groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2921)
      	groovy.lang.ExpandoMetaClass.initialize(ExpandoMetaClass.java:463)
      	org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
      	org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:182)
      	org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:210)
      	org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:751)
      	groovy.lang.GroovyObjectSupport.<init>(GroovyObjectSupport.java:32)
      	groovy.lang.Closure.<init>(Closure.java:100)
      ...
      
      [deadlocked thread] [ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)':
      --------------------------------------------------------------------------------------------------
      Thread '[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'java.lang.Object@199b330c' that is held by thread '[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)''
      
      Stack trace:
      ------------
      	java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1277)
      	java.beans.Introspector.internalFindMethod(Introspector.java:1312)
      	java.beans.Introspector.findMethod(Introspector.java:1383)
      	java.beans.Introspector.findMethod(Introspector.java:1363)
      	java.beans.PropertyDescriptor.getReadMethod(PropertyDescriptor.java:179)
      	groovy.lang.MetaClassImpl.applyPropertyDescriptors(MetaClassImpl.java:2215)
      	groovy.lang.MetaClassImpl.setupProperties(MetaClassImpl.java:1995)
      	groovy.lang.MetaClassImpl.addProperties(MetaClassImpl.java:2950)
      	groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:2921)
      	groovy.lang.ExpandoMetaClass.initialize(ExpandoMetaClass.java:463)
      	org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
      	org.codehaus.groovy.reflection.ClassInfo.getMetaClass(ClassInfo.java:182)
      	org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:210)
      	org.codehaus.groovy.runtime.InvokerHelper.getMetaClass(InvokerHelper.java:751)
      	groovy.lang.GroovyObjectSupport.<init>(GroovyObjectSupport.java:32)
      	groovy.lang.Closure.<init>(Closure.java:100) 
      ...
      

      Another log entry on the same issue with more lock information:

      "[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'" id=20 idx=0x64 tid=6450 prio=5 alive, blocked, native_blocked, daemon
          -- Blocked trying to get lock: java/beans/PropertyDescriptor@0xd62fc600[thin lock]
          at jrockit/vm/Threads.sleep(I)V(Native Method)
          at jrockit/vm/Locks.waitForThinRelease(Locks.java:955)
          at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1083)[optimized]
          at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1005)[optimized]
          at jrockit/vm/Locks.monitorEnter(Locks.java:2179)[optimized]
          at java/beans/PropertyDescriptor.getReadMethod(PropertyDescriptor.java:158)
          at java/beans/Introspector.processPropertyDescriptors(Introspector.java:683)
          at java/beans/Introspector.getTargetPropertyInfo(Introspector.java:615)
          at java/beans/Introspector.getBeanInfo(Introspector.java:407)
          at java/beans/Introspector.getBeanInfo(Introspector.java:164)
          ^-- Holding lock: java/lang/Object@0xd44d84c8[thin lock]
          at groovy/lang/MetaClassImpl$15.run(MetaClassImpl.java:2940)
          at jrockit/vm/AccessController.doPrivileged(AccessController.java:254)
          at jrockit/vm/AccessController.doPrivileged(AccessController.java:268)
          at groovy/lang/MetaClassImpl.addProperties(MetaClassImpl.java:2938)
          at groovy/lang/MetaClassImpl.initialize(MetaClassImpl.java:2921)
          ^-- Holding lock: groovy/lang/ExpandoMetaClass@0xccc4eef8[recursive]
          at groovy/lang/ExpandoMetaClass.initialize(ExpandoMetaClass.java:463)
          ^-- Holding lock: groovy/lang/ExpandoMetaClass@0xccc4eef8[thin lock]
          at org/codehaus/groovy/reflection/ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
          at org/codehaus/groovy/reflection/ClassInfo.getMetaClass(ClassInfo.java:182)
          at org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:210)
          at org/codehaus/groovy/runtime/InvokerHelper.getMetaClass(InvokerHelper.java:751)
          at groovy/lang/GroovyObjectSupport.<init>(GroovyObjectSupport.java:32)
          at groovy/lang/Closure.<init>(Closure.java:100)
      ...
      
      "[ACTIVE] ExecuteThread: '3' for queue: 'weblogic.kernel.Default (self-tuning)'" id=39 idx=0x9c tid=6558 prio=5 alive, blocked, native_blocked, daemon
          -- Blocked trying to get lock: java/lang/Object@0xd44d84c8[thin lock]
          at jrockit/vm/Threads.sleep(I)V(Native Method)
          at jrockit/vm/Locks.waitForThinRelease(Locks.java:955)
          at jrockit/vm/Locks.monitorEnterSecondStageHard(Locks.java:1083)[optimized]
          at jrockit/vm/Locks.monitorEnterSecondStage(Locks.java:1005)[optimized]
          at jrockit/vm/Locks.monitorEnter(Locks.java:2179)[optimized]
          at java/beans/Introspector.getPublicDeclaredMethods(Introspector.java:1277)
          at java/beans/Introspector.internalFindMethod(Introspector.java:1312)
          at java/beans/Introspector.findMethod(Introspector.java:1383)
          at java/beans/Introspector.findMethod(Introspector.java:1363)
          at java/beans/PropertyDescriptor.getReadMethod(PropertyDescriptor.java:179)
          ^-- Holding lock: java/beans/PropertyDescriptor@0xd62fc600[thin lock]
          at groovy/lang/MetaClassImpl.applyPropertyDescriptors(MetaClassImpl.java:2215)
          at groovy/lang/MetaClassImpl.setupProperties(MetaClassImpl.java:1995)
          at groovy/lang/MetaClassImpl.addProperties(MetaClassImpl.java:2950)
          at groovy/lang/MetaClassImpl.initialize(MetaClassImpl.java:2921)
          ^-- Holding lock: groovy/lang/ExpandoMetaClass@0xccc11b48[recursive]
          at groovy/lang/ExpandoMetaClass.initialize(ExpandoMetaClass.java:463)
          ^-- Holding lock: groovy/lang/ExpandoMetaClass@0xccc11b48[thin lock]
          at org/codehaus/groovy/reflection/ClassInfo.getMetaClassUnderLock(ClassInfo.java:166)
          at org/codehaus/groovy/reflection/ClassInfo.getMetaClass(ClassInfo.java:182)
          at org/codehaus/groovy/runtime/metaclass/MetaClassRegistryImpl.getMetaClass(MetaClassRegistryImpl.java:210)
          at org/codehaus/groovy/runtime/InvokerHelper.getMetaClass(InvokerHelper.java:751)
          at groovy/lang/GroovyObjectSupport.<init>(GroovyObjectSupport.java:32)
          at groovy/lang/Closure.<init>(Closure.java:100)
      ...
      

      It looks quite clear that two threads are trying to create a groovy.lang.Closure and the parallel execution of groovy.lang.MetaClassImpl.addProperties method can lead to a deadlock between synchronization on BEANINFO_CACHE object in java.beans.Introspector and synchronized java.beans.PropertyDescriptor.getReadMethod method.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            mropka Michal Ropka
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: