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);
}
}
/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);
}
}
- duplicates
-
JDK-4139362 recursion dumps core when JIT enabled.
-
- Closed
-