United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8012326 : Deadlock occurs when Charset.availableCharsets() is called by several threads at the same time

Details
Type:
Bug
Submit Date:
2013-04-16
Status:
Closed
Updated Date:
2014-02-12
Project Name:
JDK
Resolved Date:
2013-05-14
Component:
core-libs
OS:
windows_7
Sub-Component:
java.nio.charsets
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
6u30,6u43,8
Fixed Versions:

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

Description
When several threads call availableCharsets() , a deadlock seems to occur.
The following thread dump is gotten in JDK8b83 by using jvisualVM.

===>
2013-04-16 15:09:15
Full thread dump Java HotSpot(TM) 64-Bit Server VM (25.0-b24 mixed mode):

"Thread-1" #10 prio=5 os_prio=0 tid=0x000000000a8b2800 nid=0x1024 waiting for monitor entry [0x0000000009d2d000]
   java.lang.Thread.State: BLOCKED (on object monitor)
	at sun.nio.cs.AbstractCharsetProvider.aliases(AbstractCharsetProvider.java:195)
	- waiting to lock <0x00000000eb378d48> (a sun.nio.cs.ext.ExtendedCharsets)
	at sun.nio.cs.ext.ExtendedCharsets.aliasesFor(ExtendedCharsets.java:1297)
	at sun.nio.cs.ext.JIS_X_0208_MS5022X.<init>(JIS_X_0208_MS5022X.java:41)
	at sun.nio.cs.ext.MS50220.<clinit>(MS50220.java:61)
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:266)
	at sun.nio.cs.AbstractCharsetProvider.lookup(AbstractCharsetProvider.java:142)
	at sun.nio.cs.AbstractCharsetProvider.access$000(AbstractCharsetProvider.java:45)
	at sun.nio.cs.AbstractCharsetProvider$1.next(AbstractCharsetProvider.java:183)
	- locked <0x00000000eb3bfe70> (a sun.nio.cs.ext.ExtendedCharsets)
	at sun.nio.cs.AbstractCharsetProvider$1.next(AbstractCharsetProvider.java:173)
	at java.nio.charset.Charset.put(Charset.java:552)
	at java.nio.charset.Charset.access$300(Charset.java:275)
	at java.nio.charset.Charset$4.run(Charset.java:594)
	at java.nio.charset.Charset$4.run(Charset.java:586)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.nio.charset.Charset.availableCharsets(Charset.java:585)
	at Test.run(Test.java:23)

   Locked ownable synchronizers:
	- None

"Thread-0" #9 prio=5 os_prio=0 tid=0x0000000009071800 nid=0x898 in Object.wait() [0x000000000ae0e000]
   java.lang.Thread.State: RUNNABLE
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:266)
	at sun.nio.cs.AbstractCharsetProvider.lookup(AbstractCharsetProvider.java:142)
	at sun.nio.cs.AbstractCharsetProvider.access$000(AbstractCharsetProvider.java:45)
	at sun.nio.cs.AbstractCharsetProvider$1.next(AbstractCharsetProvider.java:183)
	- locked <0x00000000eb378d48> (a sun.nio.cs.ext.ExtendedCharsets)
	at sun.nio.cs.AbstractCharsetProvider$1.next(AbstractCharsetProvider.java:173)
	at java.nio.charset.Charset.put(Charset.java:552)
	at java.nio.charset.Charset.access$300(Charset.java:275)
	at java.nio.charset.Charset$4.run(Charset.java:594)
	at java.nio.charset.Charset$4.run(Charset.java:586)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.nio.charset.Charset.availableCharsets(Charset.java:585)
	at Test.run(Test.java:23)

   Locked ownable synchronizers:
	- None

"Service Thread" #8 daemon prio=9 os_prio=0 tid=0x000000000903f000 nid=0x136c runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"C2 CompilerThread1" #7 daemon prio=9 os_prio=2 tid=0x000000000902b800 nid=0xc78 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"C2 CompilerThread0" #6 daemon prio=9 os_prio=2 tid=0x0000000009012800 nid=0x758 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Attach Listener" #5 daemon prio=5 os_prio=2 tid=0x0000000009010000 nid=0xaa8 waiting on condition [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Signal Dispatcher" #4 daemon prio=9 os_prio=2 tid=0x0000000009001000 nid=0xf88 runnable [0x0000000000000000]
   java.lang.Thread.State: RUNNABLE

   Locked ownable synchronizers:
	- None

"Finalizer" #3 daemon prio=8 os_prio=1 tid=0x0000000008fab800 nid=0xf44 in Object.wait() [0x000000000a03e000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x00000000eb2b57a0> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:135)
	- locked <0x00000000eb2b57a0> (a java.lang.ref.ReferenceQueue$Lock)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:151)
	at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:177)

   Locked ownable synchronizers:
	- None

"Reference Handler" #2 daemon prio=10 os_prio=2 tid=0x0000000008fa1800 nid=0xedc in Object.wait() [0x0000000009e4e000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x00000000eb2b5350> (a java.lang.ref.Reference$Lock)
	at java.lang.Object.wait(Object.java:502)
	at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:142)
	- locked <0x00000000eb2b5350> (a java.lang.ref.Reference$Lock)

   Locked ownable synchronizers:
	- None

"main" #1 prio=5 os_prio=0 tid=0x0000000001b9d000 nid=0xc58 in Object.wait() [0x00000000027ef000]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x00000000eb341ce0> (a Test)
	at java.lang.Thread.join(Thread.java:1261)
	- locked <0x00000000eb341ce0> (a Test)
	at java.lang.Thread.join(Thread.java:1335)
	at Test.main(Test.java:16)

   Locked ownable synchronizers:
	- None

"VM Thread" os_prio=2 tid=0x0000000008f9d000 nid=0x3c8 runnable 

"GC task thread#0 (ParallelGC)" os_prio=0 tid=0x00000000023d5000 nid=0xd1c runnable 

"GC task thread#1 (ParallelGC)" os_prio=0 tid=0x00000000023d7000 nid=0x1348 runnable 

"VM Periodic Task Thread" os_prio=2 tid=0x0000000009049800 nid=0x1330 waiting on condition 

JNI global references: 6

<===

CONFIGURATION :
JDK : JDK8b83(x64)/JDK6u43(x86)

java version "1.8.0-ea"
Java(TM) SE Runtime Environment (build 1.8.0-ea-b83)
Java HotSpot(TM) 64-Bit Server VM (build 25.0-b24, mixed mode)

java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) Client VM (build 20.14-b01, mixed mode)

OS : Windows7(SP1 untimate, Japanese)

REPRODUCE:
1. Compile attached Test.java
2. Run "java Test"

The program outputs "OK" when it ends normally.
If not, there will not be any message in dos prompt and program does not terminates.
Then press "ctl-break" to get thread dump (or monitoring the process in jvisualvm) 

NOTE:
- It depends on timing to reporduce this problem.
 (I attached .bat which iterates java command.)
- This problem seems related to 6898310.
  (This problem does not occur in 6u29 and comes to occur in 6u30.)

                                    

Comments
verified by executing attached test
                                     
2013-07-31
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/08ef70f60e0d
User:  lana
Date:  2013-05-21 18:20:30 +0000

                                     
2013-05-21
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/08ef70f60e0d
User:  sherman
Date:  2013-05-14 21:11:42 +0000

                                     
2013-05-14
We are having multiple instances of ExtendedCharsetProvider when Charset.availableCharsets() is invoked from multiple threads the same time like in this use scenario.
                                     
2013-05-02



Hardware and Software, Engineered to Work Together