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

TTY: jdb sometimes loses current thread after hitting a breakpoint

XMLWordPrintable

    • beta2
    • generic
    • generic
    • Not verified



      Name: tb29552 Date: 03/06/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)



      If a breakpoint happens immediately after "cont"
      or "resume" command (e.g. if a breakpoint is set inside
      a tight loop) then from time to time jdb loses track of
      the current thread
      these is cause by a race in jdb code
      look at tty/Commands.java

          void commandCont() {
              if (ThreadInfo.current == null) {
                  out.println("Nothing suspended.");
                  return;
              }
              Env.vm().resume();
              ThreadInfo.invalidateAll();
          }

      obviously, if a next breakpoint is hit before invalidateAll()
      is finished, then invalidateAll() invalidates the breakpoint context

      Same thing for commandResume()
      (Review ID: 118077)
      ======================================================================
      tim.bell@Eng 2001-05-23

      Test case:

      % cat Test.java
      class Test {
          public int doTest(int i, int max) {
              int m = 0;
              int result = 0;
              for (int j = i; j < max; j++) {
                  result += j; // Source Line 5
                  m++;
                  m++;
              }
              return (result);
          }
         public static void main(String[] args) {
            System.out.println("Hello World");
            Test my = new Test();
            System.out.println(my.doTest(1,1000));
         }
      }

      % cat jdb.ini
      stop at Test:6
      stop at Test:7


      Easy to reproduce on a single-CPU system:


      % javac -g Test.java
      % jdb Test
      Initializing jdb...
      *** Reading commands from /tmpjava/4422139/jdb.ini
      Deferring breakpoint Test:6.
      It will be set after the class is loaded.
      > Deferring breakpoint Test:7.
      It will be set after the class is loaded.
      > > run
      run Test
      >
      VM Started: Set deferred breakpoint Test:7
      Set deferred breakpoint Test:6
      Hello World

      Breakpoint hit: thread="main", Test.doTest(), line=6, bci=11
        6 result += j; // Source Line 5

      main[1] cont

      Breakpoint hit: > thread="main", Test.doTest(), line=7, bci=18
        7 m++;

      > cont
      Nothing suspended.
      > thread 1
      main[1] cont

      Breakpoint hit: > thread="main", Test.doTest(), line=6, bci=11
        6 result += j; // Source Line 5

      > cont
      Nothing suspended.
      > thread 1
      main[1] cont

      Breakpoint hit: > thread="main", Test.doTest(), line=7, bci=18
        7 m++;

      > cont
      Nothing suspended.
      >

            tbell Tim Bell
            tbell Tim Bell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: