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

JVM fails (2 ways) instead of throwing StackOverflowError

XMLWordPrintable



      Name: gsC80088 Date: 03/06/99


      VERSION INFORMATION:

        java version "1.2"
        Classic VM (build JDK-1.2-V, native threads)
        java full version "JDK-1.2-V"

      I'm running on Windows NT 4.0 (service pack 3).


      SOURCE CODE (1): OverFlowTest.java

        public class OverFlowTest {
         public static void main(String[] a) {
          loopForever();
         }

         public static final void loopForever() {
          loopForever();
         }
        }


      SOURCE CODE (2): OverFlowTest2.java

        class OverFlowTest2 {
         public static void main(String[] g) {
          OverFlowTest2 a = new OverFlowTest2();

          System.out.println(a.loop(100000));
         }

         public final int loop(int n) {
          if (n % 100 == 0) {
           System.out.println(""+n+" to go...");
          }
          if (n == 0) {
           return 1;
          } else {
           return loop(n-1);
          }
         }
        }


      My understanding is that the first of these programs should throw a StackOverflowError (or run forever if the compiler does tail-call optimisation), and the second should either throw a StackOverflowError or terminate, printing "1". Observed behaviour is as follows:


      TRANSCRIPT:

      > javac OverFlowTest.java

      > java OverFlowTest
      A nonfatal internal JIT (3.00.078(x)) error 'Structured Exception(c00000fd)' has occurred in :
        'OverFlowTest.loopForever ()V': Interpreting method.
        Please report this error in detail to http://java.sun.com/cgi-bin/bugreport.cgi

      Exception in thread "main" java.lang.StackOverflowError
              at OverFlowTest.loopForever(OverFlowTest.java:7)
              at OverFlowTest.loopForever(OverFlowTest.java:7)
              at OverFlowTest.loopForever(OverFlowTest.java:7)
              at OverFlowTest.loopForever(OverFlowTest.java:7)
              at OverFlowTest.loopForever(OverFlowTest.java:7)
              at OverFlowTest.loopForever(OverFlowTest.java:7)
      [many more identical lines removed from transcript]


      > javac OverFlowTest2.java

      > java OverFlowTest2
      100000 to go...
      99900 to go...
      99800 to go...
      99700 to go...
      99600 to go...
      99500 to go...
      99400 to go...
      [... many similar lines removed from transcript ...]
      57600 to go...
      57500 to go...
      57400 to go...
      57300 to go...

      At this point, java crashes and I get a dialog from Windows NT:

      java.exe - Application Error
      The exception unknown software exception (0xc00000fd) occurred in the application at location 0x78003367
      Click on OK to terminate the application
      Click on CANCEL to debug the application

      I haven't tried, but perhaps there's a danger that a program like this could crash someone's browser.

      Please contact me at ###@###.### if you require more information on this behaviour.
      (Review ID: 54881)
      ======================================================================

            duke J. Duke
            gstone Greg Stone
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: