Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6199320

deadlock in locking of TimeZone class during a read

XMLWordPrintable

    • b19
    • generic, x86
    • linux, solaris_8
    • Verified

        With the following test case
        there is a deadlock.

        This is present in both 1.5.0 and 1.4.2

        import java.io.IOException;
        import java.util.Properties;
        import java.util.TimeZone;
        public class DeadlockTest
        {
          public DeadlockTest()
          {
             Properties sysproperty = System.getProperties();
             Thread1 t1 = new Thread1(sysproperty);
             Thread2 t2 = new Thread2();
             t1.start();
             t2.start();
             
          }

          /**
           *
           * @param args
           */
          public static void main(String[] args)
          {
            DeadlockTest deadlockTest = new DeadlockTest();
          }
          
          class Thread1 extends Thread
          {
            Properties sp;
            public Thread1(Properties p)
            {
              sp = p;
            }
            public void run()
            {
              try
              {
                sp.store(System.out, null);
              }catch (IOException e)
              {
                System.out.println("IOException : " + e);
              }
            }
          }
          
          class Thread2 extends Thread
          {
            public void run()
            {
              TimeZone.getTimeZone("PST");
            }
          }
        }


        ^\Full thread dump Java HotSpot(TM) Server VM (1.4.2_06-b03 mixed mode):

        "DestroyJavaVM" prio=5 tid=0x00036c48 nid=0x1 waiting on condition
        [0..ffbfef38]

        "Thread-1" prio=5 tid=0x000f8148 nid=0xc waiting for monitor entry
        [f107e000..f107fc28]
                at java.util.Hashtable.get(Hashtable.java:332)
                - waiting to lock <0xf1800560> (a java.util.Properties)
                at java.util.Properties.getProperty(Properties.java:563)
                at java.lang.System.getProperty(System.java:575)
                at
        sun.security.action.GetPropertyAction.run(GetPropertyAction.java:66)
                at java.security.AccessController.doPrivileged(Native Method)
                at
        sun.util.calendar.ZoneInfoFile.readZoneInfoFile(ZoneInfoFile.java:900)
                at
        sun.util.calendar.ZoneInfoFile.createZoneInfo(ZoneInfoFile.java:520)
                at sun.util.calendar.ZoneInfoFile.getZoneInfo(ZoneInfoFile.java:499)
                - locked <0xf5951af0> (a java.lang.Class)
                at sun.util.calendar.ZoneInfo.getTimeZone(ZoneInfo.java:524)
                at java.util.TimeZone.getTimeZone(TimeZone.java:448)
                at java.util.TimeZone.getTimeZone(TimeZone.java:444)
                - locked <0xf594d440> (a java.lang.Class)
                at DeadlockTest$Thread2.run(DeadlockTest.java:51)

        "Thread-0" prio=5 tid=0x000f7730 nid=0xb waiting for monitor entry
        [f117f000..f117fc28]
                at java.util.TimeZone.getDefault(TimeZone.java:498)
                - waiting to lock <0xf594d440> (a java.lang.Class)
                at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:500)
                at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:443)
                at java.util.Date.toString(Date.java:981)
                at java.util.Properties.store(Properties.java:531)
                - locked <0xf1800560> (a java.util.Properties)
                at DeadlockTest$Thread1.run(DeadlockTest.java:39)

        "Signal Dispatcher" daemon prio=10 tid=0x000eff10 nid=0x6 waiting on
        condition [0..0]

        "Finalizer" daemon prio=8 tid=0x000ec880 nid=0x4 in Object.wait()
        [fbf7f000..fbf7fc28]
                at java.lang.Object.wait(Native Method)
                - waiting on <0xf1800490> (a java.lang.ref.ReferenceQueue$Lock)
                at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:111)
                - locked <0xf1800490> (a java.lang.ref.ReferenceQueue$Lock)
                at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:127)
                at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

        "Reference Handler" daemon prio=10 tid=0x000ec600 nid=0x3 in
        Object.wait() [fc67f000..fc67fc28]
                at java.lang.Object.wait(Native Method)
                - waiting on <0xf1800380> (a java.lang.ref.Reference$Lock)
                at java.lang.Object.wait(Object.java:429)
                at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:115)
                - locked <0xf1800380> (a java.lang.ref.Reference$Lock)

        "VM Thread" prio=5 tid=0x000ec020 nid=0x2 runnable

        "VM Periodic Task Thread" prio=10 tid=0x000f4698 nid=0xa waiting on
        condition
        "Suspend Checker Thread" prio=10 tid=0x000ef610 nid=0x5 runnable

        Found one Java-level deadlock:
        =============================
        "Thread-1":
          waiting to lock monitor 0x000ed100 (object 0xf1800560, a
        java.util.Properties),
          which is held by "Thread-0"
        "Thread-0":
          waiting to lock monitor 0x000ed138 (object 0xf594d440, a java.lang.Class),
          which is held by "Thread-1"

        Java stack information for the threads listed above:
        ===================================================
        "Thread-1":
                at java.util.Hashtable.get(Hashtable.java:332)
                - waiting to lock <0xf1800560> (a java.util.Properties)
                at java.util.Properties.getProperty(Properties.java:563)
                at java.lang.System.getProperty(System.java:575)
                at
        sun.security.action.GetPropertyAction.run(GetPropertyAction.java:66)
                at java.security.AccessController.doPrivileged(Native Method)
                at
        sun.util.calendar.ZoneInfoFile.readZoneInfoFile(ZoneInfoFile.java:900)
                at
        sun.util.calendar.ZoneInfoFile.createZoneInfo(ZoneInfoFile.java:520)
                at sun.util.calendar.ZoneInfoFile.getZoneInfo(ZoneInfoFile.java:499)
                - locked <0xf5951af0> (a java.lang.Class)
                at sun.util.calendar.ZoneInfo.getTimeZone(ZoneInfo.java:524)
                at java.util.TimeZone.getTimeZone(TimeZone.java:448)
                at java.util.TimeZone.getTimeZone(TimeZone.java:444)
                - locked <0xf594d440> (a java.lang.Class)
                at DeadlockTest$Thread2.run(DeadlockTest.java:51)
        "Thread-0":
                at java.util.TimeZone.getDefault(TimeZone.java:498)
                - waiting to lock <0xf594d440> (a java.lang.Class)
                at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:500)
                at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:443)
                at java.util.Date.toString(Date.java:981)
                at java.util.Properties.store(Properties.java:531)
                - locked <0xf1800560> (a java.util.Properties)
                at DeadlockTest$Thread1.run(DeadlockTest.java:39)

        Found 1 deadlock.
        ------------------------------

        with SA

        Deadlock Detection:

        Found one Java-level deadlock:
        =============================

        "Thread-1":
         waiting to lock Monitor@0x000ed0d0 (Object@0x3d400560, a java/util/Properties),
         which is held by "Thread-0"
        "Thread-0":
         waiting to lock Monitor@0x000ed108 (Object@0xd991c9b8, a java/lang/Class),
         which is held by "Thread-1"

        Found a total of 1 deadlock.

        Java Stack Trace for Thread-0
        Thread state = BLOCKED

        - public static synchronized java.util.TimeZone getDefault() @0xd991c1b0 @bci = 0, line = 498, pc = 0xf9c0a610 (Interpreted)
        - private void initialize(java.util.Locale) @0xd990dcd0 @bci = 13, line = 500, pc = 0xf9c05758 (Interpreted)
        - public void <init>(java.lang.String, java.util.Locale) @0xd990ec68 @bci = 28, line = 443, pc = 0xf9c0580c (Interpreted)
        - public java.lang.String toString() @0xd9906828 @bci = 31, line = 981, pc = 0xf9c0580c (Interpreted)
        - public synchronized void store(java.io.OutputStream, java.lang.String) @0xd982a120 @bci = 65, line = 531, pc = 0xf9c05758 (Interpreted)
        - public void run() @0xd9901928 @bci = 8, line = 37, pc = 0xf9c0580c (Interpreted)

        Thread Info: Thread-0
        State: BLOCKED
        Stack in use by Java: 0x3c1ff640 .. 0x3c1ffb38
        Base of Stack: 0x3c1fffa0
        Last_Java_SP: 0x3c1ff7d8
        Last_Java_FP: null
        Thread id: t@11
        PostJavaState: 0x3c1ff76c


        Java Stack Trace for Thread-1
        Thread state = BLOCKED

        - public synchronized java.lang.Object get(java.lang.Object) @0xd98291d0 @bci = 0, line = 332, pc = 0xf9c0a610 (Interpreted)
        - public java.lang.String getProperty(java.lang.String) @0xd982a240 @bci = 2, line = 563, pc = 0xf9c05758 (Interpreted)
        - public static java.lang.String getProperty(java.lang.String) @0xd9816498 @bci = 50, line = 575, pc = 0xf9c05758 (Interpreted)
        - public java.lang.Object run() @0xd986c538 @bci = 4, line = 66, pc = 0xf9c05758 (Interpreted)
        - public static native java.lang.Object doPrivileged(java.security.PrivilegedAction) @0xd984cef8 @bci = 0, pc = 0xf9c0b974 (Interpreted)
        - private static byte[] readZoneInfoFile(java.lang.String) @0xd9920478 @bci = 11, line = 900, pc = 0xf9c05758 (Interpreted)
        - private static sun.util.calendar.ZoneInfo createZoneInfo(java.lang.String) @0xd9920820 @bci = 4, line = 520, pc = 0xf9c05758 (Interpreted)
        - public static synchronized sun.util.calendar.ZoneInfo getZoneInfo(java.lang.String) @0xd9920cd0 @bci = 9, line = 499, pc = 0xf9c05758 (Interpreted)
        - public static java.util.TimeZone getTimeZone(java.lang.String) @0xd991e9b0 @bci = 3, line = 524, pc = 0xf9c05758 (Interpreted)
        - private static java.util.TimeZone getTimeZone(java.lang.String, boolean) @0xd991c770 @bci = 1, line = 448, pc = 0xf9c05758 (Interpreted)
        - public static synchronized java.util.TimeZone getTimeZone(java.lang.String) @0xd991c548 @bci = 2, line = 444, pc = 0xf9c05758 (Interpreted)
        - public void run() @0xd9902270 @bci = 2, line = 49, pc = 0xf9c05758 (Interpreted)


        Thread Info: Thread-1
        State: BLOCKED
        Stack in use by Java: 0x3c0fed50 .. 0x3c0ffb40
        Base of Stack: 0x3c0fffa0
        Last_Java_SP: 0x3c0feee8
        Last_Java_FP: null
        Thread id: t@12
        PostJavaState: 0x3c0fee7c

              sherman Xueming Shen
              msusko Mark Susko (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: