2 Replies Latest reply on Sep 5, 2007 7:39 AM by Adrian Brock

    Deadlock in DelegateUnitTestCase

    Scott Stark Master

      While doing an install of the mc I saw the install fail in the following unit test due to the deadlock shown in the thread dump:

      11824 DEBUG [DelegateUnitTestCase] Got class: class org.jboss.test.classloader.delegate.support.a.TestAbstractFactory{cl=BaseClassLoader@670fe2b9 codeSource=(file:/home/svn/JBossMC/jbossmc/classloader/target/tests-classes/ <no signer certificates>)} for org.jboss.test.classloader.delegate.support.a.TestAbstractFactory from BaseClassLoader@670fe2b9
      
      Full thread dump Java HotSpot(TM) 64-Bit Server VM (1.5.0_11-b03 mixed mode):
      
      "B" prio=1 tid=0x0000002ae35e1fa0 nid=0x536c waiting for monitor entry [0x0000000041563000..0x0000000041565c30]
       at org.jboss.classloader.spi.base.BaseClassLoader.unlock(BaseClassLoader.java:701)
       - waiting to lock <0x0000002acaf81e50> (a org.jboss.classloader.spi.base.BaseClassLoader)
       at org.jboss.classloader.spi.base.BaseClassLoader.unlock(BaseClassLoader.java:583)
       at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:286)
       at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoaderManager.java:145)
       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:193)
       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:752)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:483)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:158)
       - locked <0x0000002acaf88c70> (a org.jboss.classloader.spi.base.BaseClassLoader)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       - locked <0x0000002acaf88c70> (a org.jboss.classloader.spi.base.BaseClassLoader)
       at java.lang.ClassLoader.defineClass1(Native Method)
       at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
       at org.jboss.classloader.spi.base.BaseClassLoader.access$200(BaseClassLoader.java:58)
       at org.jboss.classloader.spi.base.BaseClassLoader$1.run(BaseClassLoader.java:279)
       at org.jboss.classloader.spi.base.BaseClassLoader$1.run(BaseClassLoader.java:246)
       at java.security.AccessController.doPrivileged(Native Method)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:244)
       - locked <0x0000002acaf88c70> (a org.jboss.classloader.spi.base.BaseClassLoader)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClassLocally(BaseClassLoader.java:217)
       at org.jboss.classloader.spi.base.BaseDelegateLoader.loadClass(BaseDelegateLoader.java:75)
       at org.jboss.classloader.spi.filter.FilteredDelegateLoader.loadClass(FilteredDelegateLoader.java:90)
       at org.jboss.classloader.spi.base.ClassLoadingTask$ThreadTask.run(ClassLoadingTask.java:449)
       at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:251)
       at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoaderManager.java:145)
       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:193)
       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:752)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:483)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:158)
       - locked <0x0000002acaf88c70> (a org.jboss.classloader.spi.base.BaseClassLoader)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at org.jboss.test.classloader.AbstractClassLoaderTest.assertLoadClass(AbstractClassLoaderTest.java:176)
       at org.jboss.test.classloader.AbstractClassLoaderTest.assertLoadClass(AbstractClassLoaderTest.java:158)
       at org.jboss.test.classloader.AbstractClassLoaderTest.assertLoadClass(AbstractClassLoaderTest.java:143)
       at org.jboss.test.classloader.delegate.test.DelegateUnitTestCase.access$100(DelegateUnitTestCase.java:54)
       at org.jboss.test.classloader.delegate.test.DelegateUnitTestCase$2.run(DelegateUnitTestCase.java:299)
      
      "A" prio=1 tid=0x0000002ae31e7220 nid=0x536b in Object.wait() [0x0000000040f5e000..0x0000000040f5fdb0]
       at java.lang.Object.wait(Native Method)
       - waiting on <0x0000002acb05a558> (a java.util.Collections$SynchronizedList)
       at java.lang.Object.wait(Object.java:474)
       at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:204)
       - locked <0x0000002acb05a558> (a java.util.Collections$SynchronizedList)
       at org.jboss.classloader.spi.base.ClassLoaderManager.process(ClassLoaderManager.java:145)
       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:193)
       at org.jboss.classloader.spi.base.BaseClassLoaderDomain.loadClass(BaseClassLoaderDomain.java:752)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:483)
       at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:158)
       - locked <0x0000002acaf81e50> (a org.jboss.classloader.spi.base.BaseClassLoader)
       at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
       at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
       - locked <0x0000002acaf81e50> (a org.jboss.classloader.spi.base.BaseClassLoader)
       at java.lang.Class.getDeclaredMethods0(Native Method)
       at java.lang.Class.privateGetDeclaredMethods(Class.java:2395)
       at java.lang.Class.getMethod0(Class.java:2642)
       at java.lang.Class.getMethod(Class.java:1579)
       at org.jboss.test.classloader.delegate.test.DelegateUnitTestCase$1.run(DelegateUnitTestCase.java:277)
      
      



        • 1. Re: Deadlock in DelegateUnitTestCase
          Ales Justin Master

           

          "scott.stark@jboss.org" wrote:
          While doing an install of the mc I saw the install fail in the following unit test due to the deadlock shown in the thread dump:

          I randomly got the same deadlock, though tests mostly passed.
          Should probably report it sooner ... :-(

          • 2. Re: Deadlock in DelegateUnitTestCase
            Adrian Brock Master

            If you can reproduce it can you try to debug it or
            add enableTrace("org.jboss.classloader") to the test.

            There's obviously a bug somewhere since thread "B" is trying to unlock
            the classloader:

            "B" prio=1 tid=0x0000002ae35e1fa0 nid=0x536c waiting for monitor entry [0x0000000041563000..0x000000004
            1565c30]
             at org.jboss.classloader.spi.base.BaseClassLoader.unlock(BaseClassLoader.java:701)
             - waiting to lock <0x0000002acaf81e50> (a org.jboss.classloader.spi.base.BaseClassLoader)
             at org.jboss.classloader.spi.base.BaseClassLoader.unlock(BaseClassLoader.java:583)
             at org.jboss.classloader.spi.base.ClassLoaderManager.nextTask(ClassLoaderManager.java:286)
            


            But at this point in the code "A" has obtained the lock:
             at org.jboss.classloader.spi.base.BaseClassLoader.loadClassFromDomain(BaseClassLoader.java:4
            83)
             at org.jboss.classloader.spi.base.BaseClassLoader.loadClass(BaseClassLoader.java:158)
             - locked <0x0000002acaf81e50> (a org.jboss.classloader.spi.base.BaseClassLoader)
            


            So the two questions are:
            1) Is this is spurious unlock and "B" didn't have the lock?
            2) Did "A" obtain the lock when it shouldn't have done?

            I'd guess it is (1) since I didn't *fully* understand the
            "release in next task" in the old LoadMgr3, I just copied the logic. :-)