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

Hang setting breakpoint in jdb while debugging Sample.java under HotJava

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.1.5
    • 1.1.2
    • core-svc
    • None
    • 1.1.5
    • x86
    • windows_nt
    • Verified



      Name: wm7046 Date: 08/01/97


      The Problem

      Here is what I did:


      D:\javabugs\sample>jdb "-Dhotjava.home=D:\Hotjava" "-Dapplet.allow.namespace=true" sun.hotjava.Main
      file:D:\javabugs\sample\sample.html
      Initializing jdb...
      0xf73128:class(sun.hotjava.Main)
      > stop in sample.init
      Breakpoint set in sample.init
      > run
      run sun.hotjava.Main file:D:\javabugs\sample\sample.html
      running ...
      main[1] [Starting HotJava]
      [Initializing globals]
      [Creating frame]
      [Loading: C:\\.hotjava\urlpool]
      [Loaded DTD html32 in 687ms]

      Breakpoint hit: sample.init (sample:107)
      thread applet-sample.class[1] list
      103 // CreateControls() method from within this method. Remove the following
      104 // call to resize() before adding the call to CreateControls();
      105 // CreateControls() does its own resizing.
      106 //----------------------------------------------------------------------
      107 => resize(320, 240);
      108
      109 // TODO: Place additional initialization code here
      110 }
      111
      thread applet-sample.class[1] next
      thread applet-sample.class[1]
      Breakpoint hit: sample.init (sample:99)
      thread applet-sample.class[1] stop in sample.displayImage



      At this point it was locked up. Totally.

      This problem was discovered with a Sparkler (1.1.4) prerelease. The problem occurs fairly infrequently - I've seen it 3 times out of maybe 20 to 30 attempts. It may be difficult to reproduce.

      Our Analysis

      The hang occurred because a program thread had been suspended holding a monitor on a Class object (the Class object for java.text.BreakIterator). After this thread was suspended, as part of new breakpoint processing, the debugger Agent called java.lang.Class.getInterfaces for the class in which the breakpoint was to be set. This caused class loading to take place for this class, and eventually caused the Agent thread to require the monitor for the same Class object (java.text.BreakIterator). The result is a deadlock. It is not at all clear how a deadlock such as this is to be avoided.

      The calling traces for the two threads may be helpful here. They are (Agent thread)


      NtWaitForSingleObject@12 + 11 bytes
      RtlpWaitForCriticalSection@4 + 170 bytes
      RtlEnterCriticalSection@4 + 67 bytes
      sysMonitorEnter(sys_mon * 0x008512e8) line 91
      monitorEnter(unsigned int 16330096) line 47 + 12 bytes
      ResolveClass(Hjava_lang_Class * 0x00f92d70, char * * 0x0201f5e8) line 546 + 9 bytes
      java_lang_Class_getInterfaces(Hjava_lang_Class * 0x00f92d70) line 123 + 13 bytes
      Java_java_lang_Class_getInterfaces_stub(stack_item * 0x01d4b0e0, execenv * 0x0201ff10) line 107 + 11 bytes
      invokeNativeMethod(Hjava_lang_Object * 0x00f92d70, methodblock * 0x01cf5020, int 1, execenv * 0x0201ff10) line 224 + 14 bytes
      ExecuteJava(unsigned char * 0x0201fe60, execenv * 0x0201ff10) line 1447 + 22 bytes
      do_execute_java_method_vararg(execenv * 0x0201ff10, void * 0x00f65620, char * 0x1007df2c, char * 0x1007df28, methodblock * 0x00000000, int 0, char * 0x0201fefc, long * 0x00000000, int 0) line 601 + 13 bytes
      execute_java_dynamic_method(execenv * 0x0201ff10, Hjava_lang_Object * 0x00f65620, char * 0x1007df2c, char * 0x1007df28) line 283 + 33 bytes
      ThreadRT0(Hjava_lang_Thread * 0x00f65620) line 61 + 23 bytes
      _start(sys_thread * 0x0087c880) line 244 + 13 bytes
      MSVCRT! 779f585d()



      and (user thread)


      NtWaitForSingleObject@12 + 11 bytes
      RtlpWaitForCriticalSection@4 + 170 bytes
      RtlEnterCriticalSection@4 + 67 bytes
      sysMonitorEnter(sys_mon * 0x00860e60) line 91
      FindClassFromClass(execenv * 0x02c8ff10, char * 0x028d8f58, int 0, Hjava_lang_Class * 0x00f92d70) line 967 + 11 bytes
      Locked_InitializeClass(Hjava_lang_Class * 0x00f92d70, char * * 0x02c8f354) line 691 + 24 bytes
      InitializeClass(Hjava_lang_Class * 0x00f92d70, char * * 0x02c8f354) line 536 + 13 bytes
      InitializeAndResolveClass(Hjava_lang_Class * 0x00f92d70, int 1) line 889 + 13 bytes
      FindClassFromClass(execenv * 0x02c8ff10, char * 0x028ecea0, int 1, Hjava_lang_Class * 0x00f80108) line 978 + 13 bytes
      Locked_ResolveClassConstant(Hjava_lang_Class * 0x00f80108, cp_item_type * 0x028eb988, unsigned int 19, execenv * 0x02c8ff10, unsigned int 128) line 218 + 19 bytes
      Locked_ResolveClassConstantField(unsigned int 10, Hjava_lang_Class * 0x00f80108, cp_item_type * 0x028eb988, unsigned int 74, execenv * 0x02c8ff10) line 337 + 29 bytes
      Locked_ResolveClassConstant(Hjava_lang_Class * 0x00f80108, cp_item_type * 0x028eb988, unsigned int 74, execenv * 0x02c8ff10, unsigned int 1024) line 311 + 25 bytes
      ResolveClassConstant(cp_item_type * 0x028eb988, unsigned int 74, execenv * 0x02c8ff10, unsigned int 1024) line 181 + 25 bytes
      ResolveClassConstantFromPC(unsigned char * 0x028ee5a0, unsigned char 184, cp_item_type * 0x028eb988, execenv * 0x02c8ff10, unsigned int 1024) line 1272 + 21 bytes
      ExecuteJava(unsigned char * 0x02c8fe60, execenv * 0x02c8ff10) line 1058 + 70 bytes
      do_execute_java_method_vararg(execenv * 0x02c8ff10, void * 0x00f84cd8, char * 0x1007df2c, char * 0x1007df28, methodblock * 0x00000000, int 0, char * 0x02c8fefc, long * 0x00000000, int 0) line 601 + 13 bytes
      execute_java_dynamic_method(execenv * 0x02c8ff10, Hjava_lang_Object * 0x00f84cd8, char * 0x1007df2c, char * 0x1007df28) line 283 + 33 bytes
      ThreadRT0(Hjava_lang_Thread * 0x00f84cd8) line 61 + 23 bytes
      _start(sys_thread * 0x008a5f80) line 244 + 13 bytes
      MSVCRT! 779f585d()
      BaseThreadStart@8 + 81 bytes
      ======================================================================
      john.bui@eng 1997-10-17

      No specific test case available. Implicity tested, closed with exposure.

            rfield Robert Field (Inactive)
            mmma Marvin Ma (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: