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

JDI: ThreadReference.isSuspended() returns false for a suspended thread

XMLWordPrintable

    • generic
    • generic



      Name: elR10090 Date: 03/13/2001




      The method ThreadReference.isSuspended()
      returns false in two particular cases
      when it is applied to a thread in a debuggee
      suspended by a debugger with

      either the method ThreadReference.suspend()
      or the method VirtualMachine.suspend(),

      called after all the Event objects have been removed from
      the EventQueue object in the debugger.

      Tests show that
      after making EventQueue empty,
      in the following method call sequences

            ThreadReference.suspend();
            ThreadReference.suspendCount();
            ThreadReference.isSuspended();
      and
            VirtualMachine.suspend();
            ThreadReference.suspendCount();
            ThreadReference.isSuspended();

      the value returned by the method
          ThreadReference.suspendCount(), is not equal to 0
      but the value returned by the method
          ThreadReference.isSuspended(), is false.


      These incorrect returned results are observed
      for JDI versions 1.3.1-rc1-b18 and 1.4.0-beta-b55
      when HS 1.3.1-rc1-b18, or HS 1.4.0-beta-b55, is runnning a test program
      on the following H/S configurations:

       - SUNW Ultra1: sparc 200MHz, RAM 128Mb;
         OS: Solaris-8;
         JVM: Client & Server
       - Intel: two Pentium-III 600MHz processors, RAM 512Mb;
         OS: Solaris-8;
         JVM: Client & Server
       - Intel: two Pentium-III 600MHz processors, RAM 512Mb;
         OS: Linux/RedHat6.2;
         JVM: Client & Server
       - Intel: Pentium-II 350MHz, RAM 128Mb;
         OS: WinNT/4-Workstation;
         JVM: Client & Server


      Corresponding code fragment in the debugger
      and corresponding log for the tested cases with comments
      showing particular incorrect returned values, are below.


      Steps to reproduce the bug:
      1. cd /net/sqesvr.eng/export/vsn/GammaBase/Bugs/{this bug ID}
      2. ksh doit003.sh {JAVA_HOME}
          or
      2. ksh doit004.sh {JAVA_HOME}


      The tests will be in the next release of testbase_nsk
      which is accessable through:

          /net/sqesvr.eng/export/vsn/VM/testbase/testbase_nsk


          This bug affects the following testbase_nsk tests:
          
          nsk/jdi/ThreadReference/isSuspended/issuspended003
          nsk/jdi/ThreadReference/isSuspended/issuspended004



      ///////////////////////////////////////////////////////////////////////

      // code fragments in the debugger
      //
      // test: nsk/jdi/ThreadReference/isSuspended/issuspended003
      //
      // note: in the test nsk/jdi/ThreadReference/isSuspended/issuspended004
      // there is the statement
      // vm.suspend();
      // instead of
      // threadRef.suspend();


      EventSet eventSet = null;
                              
      log2(" deleting events from EventQueue");

      for (;;) {
                              
          log2(" new: eventSet = eventQueue.remove(10000);");
          try {
              eventSet = eventQueue.remove(10000);
          } catch ( Throwable e ) {
              log3("ERROR: eventSet = eventQueue.remove() : " + e);
              expresult = 1;
              break;
          }
          
          if (eventSet != null) {
              log2(" : eventSet != null; size == " + eventSet.size());
              EventIterator eIter = eventSet.eventIterator();
              Event ev = null;
              
              for (; eIter.hasNext(); ) {
                  ev = eIter.nextEvent();

           ll : for (int ifor =0; ; ifor++) {
       
                      try {
                        switch (ifor) {
                
                        case 0: AccessWatchpointEvent awe = (AccessWatchpointEvent) ev;
                                log2(" AccessWatchpointEvent removed");
                                break ll;
                        case 1: BreakpointEvent be = (BreakpointEvent) ev;
                                log2(" BreakpointEvent removed");
                                break ll;
                        case 2: ClassPrepareEvent cpe = (ClassPrepareEvent) ev;
                                log2(" ClassPreparEvent removed");
                                break ll;
                        case 3: ClassUnloadEvent cue = (ClassUnloadEvent) ev;
                                log2(" ClassUnloadEvent removed");
                                break ll;
                        case 4: ExceptionEvent ee = (ExceptionEvent) ev;
                                log2(" ExceptionEvent removed");
                                break ll;
                        case 5: MethodEntryEvent mene = (MethodEntryEvent) ev;
                                log2(" MethodEntryEvent removed");
                                break ll;
                        case 6: MethodExitEvent mexe = (MethodExitEvent) ev;
                                log2(" MethodExiEvent removed");
                                break ll;
                        case 7: ModificationWatchpointEvent mwe = (ModificationWatchpointEvent) ev;
                                log2(" ModificationWatchpointEvent removed");
                                break ll;
                        case 8: StepEvent se = (StepEvent) ev;
                                log2(" StepEvent removed");
                                break ll;
                        case 9: ThreadDeathEvent tde = (ThreadDeathEvent) ev;
                                log2(" ThreadDeathEvent removed");
                                break ll;
                        case 10: ThreadStartEvent tse = (ThreadStartEvent) ev;
                                log2(" ThreadStartEvent removed");
                                break ll;
                        case 11: VMDeathEvent vmde = (VMDeathEvent) ev;
                                log2(" VMDeathEvent removed");
                                break ll;
                        case 12: VMStartEvent vmse = (VMStartEvent) ev;
                                log2(" VMStartEvent removed");
                                break ll;
                        case 13: WatchpointEvent we = (WatchpointEvent) ev;
                                log2(" WatchpointEvent removed");
                                break ll;
                        
                       default: log2(" default case for casting event");
                                break ll;
                       } // end of switch
                     } catch ( ClassCastException e ) {
                     }
                 } // ll:
             } // for (; ev.hasNext(); ) {
                       
          } else {
             log2(" : eventSet == null: EventQueue is empty");
             break;
          }
      }


      log2(" checking up before to begin testing the thread");
      if (!threadRef.isSuspended()) {
          log2(" : !thread2.isSuspended()");
          log2(" thread2.suspendCount() == " + threadRef.suspendCount());
      } else {
          log3("ERROR: thread2.isSuspended()");
          log2(" thread2.suspendCount() == " + threadRef.suspendCount());
          expresult = 1;
      }

      log2(" suspending thread2 with threadRef.suspend();");
      threadRef.suspend();
                              
      int suspCount = threadRef.suspendCount();
      boolean isSusp = threadRef.isSuspended();
                              
      log2(" thread2.suspendCount() == " + suspCount);
      if (suspCount != 0)
          if (isSusp) {
              log2(" : thread2.isSuspended()");
          } else {
              log3("ERROR: !thread2.isSuspended()");
              expresult = 1;
          }



      ======================================================
      // logs with comments


      // log for the method: ThreadReference.suspend()
      //
      // test : nsk/jdi/ThreadReference/isSuspended/issuspended003



      ==> nsk/jdi/ThreadReference/isSuspended/issuspended003 TESTING BEGINS
      debugee.err> **> issuspended003a: waiting for an instruction from the debugger ...
      debugee.err> **> issuspended003a: thread1 is in: synchronized (lockingObject) {
      debugee.err> **> issuspended003a: creating and starting up thread2
      debugee.err> **> issuspended003a: thread2 method 'run' enter

      ==> nsk/jdi/ThreadReference/isSuspended/issuspended003 new checkready: #0
      --> issuspended003: new check: #0
      --> issuspended003: setting up breakpoints within 'runt1'
      --> issuspended003: setting up a breakpoint within 'runt2'
      --> issuspended003: checking up before to make eventQueue empty
      --> issuspended003: : !threadRef.isSuspended()
      --> issuspended003: suspendCount == 0
      --> issuspended003: new: eventSet = eventQueue.remove(10000);
      --> issuspended003: : eventSet != null; size == 1
      --> issuspended003: VMStartEvent removed
      --> issuspended003: new: eventSet = eventQueue.remove(10000);
      --> issuspended003: : eventSet == null: EventQueue is empty
                                                    ^^^^^^^^^^^^^^^^^^^

      --> issuspended003: checking up before to begin testing the thread
      --> issuspended003: : !thread2.isSuspended()
      --> issuspended003: thread2.suspendCount() == 0
      --> issuspended003: suspending thread2 with threadRef.suspend();
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      --> issuspended003: thread2.suspendCount() == 1
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^

      ##> issuspended003: ERROR: !thread2.isSuspended()
                                  ^^^^^^^^^^^^^^^^^^^^^
                                  thread2 is not suspended whereas
                                  the above method suspendCount()
                                  shows the value of the count is not equal to 0.


      ##> issuspended003: ERROR: expresult != true; check # = 0
      --> issuspended003: new check: #1
      --> issuspended003: test cases finished
      debugee.err> **> issuspended003a: thread1 is out of: synchronized (lockingObject) {
      debugee.err> **> issuspended003a: waiting for an instruction from the debugger ...
      --> issuspended003: : returned string is 'checkend'

      ==> nsk/jdi/ThreadReference/isSuspended/issuspended003 TESTING ENDS
      --> issuspended003: waiting for the debuggee to finish ...
      debugee.err> **> issuspended003a: waiting for an instruction from the debugger ...
      debugee.err> **> issuspended003a: 'quit' recieved
      --> issuspended003: debuggee returned expected exit status: 95 == PASS_BASE
      TEST FAILED



      // log for the method: VirtualMachine.suspend()
      //
      // test: nsk/jdi/ThreadReference/isSuspended/issuspended004


      ==> nsk/jdi/ThreadReference/isSuspended/issuspended004 TESTING BEGINS
      debugee.err> **> issuspended004a: waiting for an instruction from the debugger ...
      debugee.err> **> issuspended004a: thread1 is in: synchronized (lockingObject) {
      debugee.err> **> issuspended004a: creating and starting up thread2
      debugee.err> **> issuspended004a: thread2 method 'run' enter

      ==> nsk/jdi/ThreadReference/isSuspended/issuspended004 new checkready: #0
      --> issuspended004: new check: #0
      --> issuspended004: setting up breakpoints within 'runt1'
      --> issuspended004: setting up a breakpoint within 'runt2'
      --> issuspended004: checking up before to make eventQueue empty
      --> issuspended004: : !threadRef.isSuspended()
      --> issuspended004: suspendCount == 0
      --> issuspended004: new: eventSet = eventQueue.remove(10000);
      --> issuspended004: : eventSet != null; size == 1
      --> issuspended004: VMStartEvent removed
      --> issuspended004: new: eventSet = eventQueue.remove(10000);
      --> issuspended004: : eventSet == null: EventQueue is empty
                                                    ^^^^^^^^^^^^^^^^^^^

      --> issuspended004: checking up before to begin testing the thread
      --> issuspended004: : !thread2.isSuspended()
      --> issuspended004: thread2.suspendCount() == 0
      --> issuspended004: suspending thread2 with vm.suspend();
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      --> issuspended004: thread2.suspendCount() == 1
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

      ##> issuspended004: ERROR: !thread2.isSuspended()
                                  ^^^^^^^^^^^^^^^^^^^^^
                                  thread2 is not suspended whereas
                                  the above method suspendCount()
                                  shows the value of the count is not equal to 0.


      ##> issuspended004: ERROR: expresult != true; check # = 0
      --> issuspended004: new check: #1
      --> issuspended004: test cases finished
      debugee.err> **> issuspended004a: thread2 enters in synchronized block
      debugee.err> **> issuspended004a: thread2 exits from synchronized block
      debugee.err> **> issuspended004a: thread2 method 'runt1' enter 1
      debugee.err> **> issuspended004a: thread1 is out of: synchronized (lockingObject) {
      debugee.err> **> issuspended004a: waiting for an instruction from the debugger ...
      --> issuspended004: : returned string is 'checkend'

      ==> nsk/jdi/ThreadReference/isSuspended/issuspended004 TESTING ENDS
      --> issuspended004: waiting for the debuggee to finish ...
      debugee.err> **> issuspended004a: waiting for an instruction from the debugger ...
      debugee.err> **> issuspended004a: 'quit' recieved
      --> issuspended004: debuggee returned expected exit status: 95 == PASS_BASE
      TEST FAILED

      ----------------------------------------------------------------------



      ======================================================================

            rfield Robert Field (Inactive)
            latkinsunw Latkin Latkin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: