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

Program never terminates with JIT on

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P5 P5
    • None
    • 1.2.0
    • vm-legacy


      The following program never terminates when running it with
      the JIT on. It works fine if I run it with -Djava.compiler=symcjit.
      It runs fine with the HotSpot VM too.


      ---- session ----
      D:\renes\opto\testing>java -classic -Djava.compiler=NONE Loop2
      Main started
      Count 0
      loop started
      Count -218303
      Send kill signal
      Thread is dead
      java.lang.ThreadDeath
      loop ended

      D:\renes\opto\testing>java -classic Loop2
      Main started
      loop started
      Count 0
      Count -5036218
      Send kill signal
      Thread is dead
      ^C <==== HANGS

      D:\renes\opto\testing>java -classic -version
      java version "1.2"
      Classic VM (build JDK-1.2-V, native threads)


      ----- Loop2.java ------
      class Counter implements Runnable {

        int _count = 0;

        public void run() {
          loop(false);
        }

        boolean _once;

        void loop(boolean once) {
          System.out.println("loop started");
          try {
          for(int j = 1; j < 32767 * 32767; j++) {
            for(int i = 1; i < 32767 * 32767; i++) {
              _count += _count + i * j;
            }
          }
          } catch(Throwable e) {
           System.out.println(e);
          } finally {
            System.out.println("loop ended");
          }
        }

        int getCount() { return _count; }
      }



      public class Loop2 {

        public static void main(String[] args) {
          System.out.println("Main started");
          Counter c = new Counter();

          Thread t = new Thread(c);
          t.start();


          for(int i = 0; i < 2; i++) {
            System.out.println("Count " + c.getCount());
            System.gc();
            pause();
          }

          System.out.println("Send kill signal");
          t.stop();

          while(t.isAlive()) {
            pause();
          }
          System.out.println("Thread is dead");
         }

         static void pause() {
           try {
             Thread.sleep(50);
           } catch(InterruptedException e) {}
         }
      }

            duke J. Duke
            rschmidtsunw Rene Schmidt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: