JDK-6977738 : Deadlock between java.lang.ClassLoader and java.util.Properties
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 6u21,7
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2010-08-17
  • Updated: 2016-05-11
  • Resolved: 2010-10-26
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
7 b116Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
Stress test hangs with stack trace:

Java stack information for the threads listed above:
===================================================
"Thread-79":
        at java.util.Hashtable.get(Hashtable.java:356)
        - waiting to lock <0x00000000f0007af0> (a java.util.Properties)
        at java.util.Properties.getProperty(Properties.java:949)
        at java.lang.System.getProperty(System.java:703)
        at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:84)
        at sun.security.action.GetPropertyAction.run(GetPropertyAction.java:49)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.misc.Launcher.getBootstrapClassPath(Launcher.java:384)
        - locked <0x00000000eae2d058> (a java.lang.Class for sun.misc.Launcher)
        at java.lang.ClassLoader.getBootstrapClassPath(ClassLoader.java:1320)
        at java.lang.ClassLoader.getBootstrapResource(ClassLoader.java:1295)
        at java.lang.ClassLoader.getResource(ClassLoader.java:1132)
        at java.lang.ClassLoader.getResource(ClassLoader.java:1130)
        at java.lang.ClassLoader.getResource(ClassLoader.java:1130)
        at java.lang.ClassLoader.getResourceAsStream(ClassLoader.java:1339)
        at javasoft.sqe.tests.vm.concepts.classes004.classes00401.KlassLoader.findClass(classes00401.java:45)
        - locked <0x00000000f00135a8> (a javasoft.sqe.tests.vm.concepts.classes004.classes00401.KlassLoader)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:422)
        - locked <0x00000000f00135a8> (a javasoft.sqe.tests.vm.concepts.classes004.classes00401.KlassLoader)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:355)
        at javasoft.sqe.tests.vm.concepts.classes004.classes00401.classes00401.run(classes00401.java:18)
        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:613)
        at nsk.stress.share.StressTest$TestThread.runTest(StressTest.java:722)
        at nsk.stress.share.StressTest$TestThread.run(StressTest.java:755)
"Thread-68":
        at sun.misc.Launcher.getBootstrapClassPath(Launcher.java:383)
        - waiting to lock <0x00000000eae2d058> (a java.lang.Class for sun.misc.Launcher)
        at java.lang.ClassLoader.getBootstrapClassPath(ClassLoader.java:1320)
        at java.lang.ClassLoader.getBootstrapResources(ClassLoader.java:1306)
        at java.lang.ClassLoader.getResources(ClassLoader.java:1171)
        at java.util.ServiceLoader$LazyIterator.hasNext(ServiceLoader.java:340)
        at java.util.ServiceLoader$1.hasNext(ServiceLoader.java:432)
        at sun.util.LocaleServiceProviderPool$1.run(LocaleServiceProviderPool.java:118)
        at java.security.AccessController.doPrivileged(Native Method)
        at sun.util.LocaleServiceProviderPool.<init>(LocaleServiceProviderPool.java:116)
        at sun.util.LocaleServiceProviderPool.getPool(LocaleServiceProviderPool.java:98)
        at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:104)
        at sun.util.TimeZoneNameUtility.retrieveDisplayNames(TimeZoneNameUtility.java:99)
        at java.util.TimeZone.getDisplayNames(TimeZone.java:416)
        at java.util.TimeZone.getDisplayName(TimeZone.java:367)
        at java.util.Date.toString(Date.java:1042)
        at java.util.Properties.store0(Properties.java:824)
        at java.util.Properties.store(Properties.java:813)
        at java.util.Properties.save(Properties.java:710)
        - locked <0x00000000f0007af0> (a java.util.Properties)
        at javasoft.sqe.tests.vm.concepts.unicode001.unicode00103.unicode00103.run(unicode00103.java:78)
        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:613)
        at nsk.stress.share.StressTest$TestThread.runTest(StressTest.java:722)
        at nsk.stress.share.StressTest$TestThread.run(StressTest.java:755)

Found 1 deadlock.

Comments
Updated changeset link: http://hg.openjdk.java.net/jdk7/jdk7/jdk/rev/b444f86c4abe
11-05-2016

EVALUATION Changeset: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/b444f86c4abe
14-10-2010

EVALUATION java.util.zip.ZipFile also gets the system property in its initialization that might be called during the getResource() call and it is another potential place causing a deadlock.
17-09-2010

EVALUATION The deadlock happens as follows: One thread (A) tries to get a resource from a system class (from the bootclasspath), it synchronizes on the sun.misc.Launcher object and attempts to acquire the lock of the system properties object in order to get the "sun.boot.class.path" system property. Another thread (B) is holding the monitor lock of the system properties object when it calls the Properties.save() method to write the property list to a given output stream. The Properties.save() method writes the current date and time while holding the lock of the system properties object that causes the threads to deadlock. Getting the current date/time (calling Date.toString()) first finds if a TimeZone name service provider exists and that attempts to acquire the sun.misc.Launcher object lock which is being held by thread A. The Properties.save() method should confine the synchronization to access of the property list and release the lock when it calls methods in other classes.
17-08-2010