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

Solaris JIT dumps core in recursive method, instead of throwing stack overflow

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • vm-legacy
    • None
    • jit
    • sparc
    • solaris_2.6

      This only happens on Solaris, not on win32, and then only with the JIT enabled.

      /home/ovrskeek> printenv JAVA_COMPILER
      /home/ovrskeek> java -version
      java version "1.2beta4"
      Classic VM (build JDK-1.2beta4-K, green threads, sunwjit)
      /home/ovrskeek> java LockTest
      Time for 1000000 iterations (non recursive) 1490
      Segmentation fault (core dumped)
      /home/ovrskeek> setenv JAVA_COMPILER NONE
      /home/ovrskeek> java LockTest
      Time for 1000000 iterations (non recursive) 1890
      Exception in thread "main" java.lang.StackOverflowError
              at LockTest.recursiveLock(LockTest.java:28)
              at LockTest.recursiveLock(LockTest.java:28)
              at LockTest.recursiveLock(LockTest.java:28)
              at LockTest.recursiveLock(LockTest.java:28)
              at LockTest.recursiveLock(LockTest.java:28)
              at LockTest.recursiveLock(LockTest.java:28)
              at LockTest.recursiveLock(LockTest.java:28)
              at LockTest.recursiveLock(LockTest.java:28)

      [....]

      public class LockTest extends Object
      {
          static int loopCount = 1000000;
          static String target = "FooBar!";

          public static void main(String[] argv) {
              long t1 = System.currentTimeMillis();
              int i=0;
              while(i<loopCount)
              {
                  synchronized(target) {
                      i++;
                  }
              }
              long t2 = System.currentTimeMillis();
              System.err.println("Time for " + loopCount + " iterations (non recursive) " + (t2-t1));

              t1 = System.currentTimeMillis();
              recursiveLock(loopCount);
              t2 = System.currentTimeMillis();
              System.err.println("Time for " + loopCount + " iterations (recursive, includes method call overhead) " + (t2-t1));
          }

          static synchronized void recursiveLock(int val) {
              if(val == 0)
                  return;
              else
                  recursiveLock(val-1);
          }
      }

            never Tom Rodriguez
            jmcilreesunw James Mcilree (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: