JDK-7191454 : CacheEntry.getJarFile might get dead-lock with CacheJarFile.close()
  • Type: Bug
  • Component: deploy
  • Sub-Component: deployment_toolkit
  • Affected Version: 7u6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2012-08-14
  • Updated: 2012-12-13
  • Resolved: 2012-08-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u10Fixed 8 b53Fixed
Description
Automate deployment automate unit test run on some platform get hanged with following deadlock:

Found one Java-level deadlock:
=============================
"Thread-1":
   waiting to lock monitor 0x0820f248 (object 0xe34803b0, a 
java.lang.Class),
   which is held by "Finalizer"
"Finalizer":
   waiting to lock monitor 0x0820ee60 (object 0xe3301348, a 
com.sun.deploy.cache.CacheEntry),
   which is held by "main"
"main":
   waiting to lock monitor 0x0820f248 (object 0xe34803b0, a 
java.lang.Class),
   which is held by "Finalizer"

Java stack information for the threads listed above:
===================================================
"Thread-1":
     at com.sun.deploy.cache.MemoryCache.shutdown(Unknown Source)
     - waiting to lock <0xe34803b0> (a java.lang.Class for 
com.sun.deploy.cache.MemoryCache)
     at com.sun.deploy.cache.MemoryCache$1.run(Unknown Source)
"Finalizer":
     at com.sun.deploy.cache.CacheEntry.getJarFile(Unknown Source)
     - waiting to lock <0xe3301348> (a com.sun.deploy.cache.CacheEntry)
     at com.sun.deploy.cache.MemoryCache.hasReferencesTo(Unknown Source)
     - locked <0xe34803b0> (a java.lang.Class for 
com.sun.deploy.cache.MemoryCache)
     at com.sun.deploy.cache.CachedJarFile.close(Unknown Source)
     at java.util.zip.ZipFile.finalize(ZipFile.java:625)
     at java.lang.ref.Finalizer.invokeFinalizeMethod(Native Method)
     at java.lang.ref.Finalizer.runFinalizer(Finalizer.java:101)
     at java.lang.ref.Finalizer.access$100(Finalizer.java:32)
     at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:178)
"main":
     at com.sun.deploy.cache.MemoryCache.addResourceReference(Unknown 
Source)
     - waiting to lock <0xe34803b0> (a java.lang.Class for 
com.sun.deploy.cache.MemoryCache)
     at com.sun.deploy.cache.CachedJarFile.<init>(Unknown Source)
     at com.sun.deploy.cache.CachedJarFile.<init>(Unknown Source)
     at com.sun.deploy.cache.CacheEntry$5.run(Unknown Source)
     at java.security.AccessController.doPrivileged(Native Method)
     at com.sun.deploy.cache.CacheEntry.getJarFile(Unknown Source)
     - locked <0xe3301348> (a com.sun.deploy.cache.CacheEntry)
     at com.sun.deploy.cache.CacheEntryTest.downloadJarFile(Unknown Source)
     at 
com.sun.deploy.cache.CacheEntryTest.testSigningData_FromCacheEntry_ToJarFile(Unknown 
Source)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:474)
     at junit.framework.TestCase.runTest(TestCase.java:168)
     at junit.framework.TestCase.runBare(TestCase.java:134)
     at sun.tests.junit.DeployTestCase.runBare(Unknown Source)
     at junit.framework.TestResult$1.protect(TestResult.java:110)
     at junit.framework.TestResult.runProtected(TestResult.java:128)
     at junit.framework.TestResult.run(TestResult.java:113)
     at junit.framework.TestCase.run(TestCase.java:124)
     at junit.framework.TestSuite.runTest(TestSuite.java:232)
     at junit.framework.TestSuite.run(TestSuite.java:227)
     at 
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
     at junit.framework.JUnit4TestAdapter.run(JUnit4TestAdapter.java:36)
     at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.run(JUnitTestRunner.java:420)
     at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUnitTestRunner.java:911)
     at 
org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnitTestRunner.java:743)

Found 1 deadlock.

Comments
EVALUATION Should avoid holding CacheEntry lock while accessing MemoryCache synchronized methods.
14-08-2012