A simple recursive program may crash JVM with EXCEPTION_STACK_OVERFLOW.
public class RecursiveCall {
static int depth;
public static void main(String[] args) {
try {
recursive();
} catch (StackOverflowError e) {
System.out.println(depth);
}
}
static void recursive() {
depth++;
recursive();
}
}
I can always reproduce it within a few minutes when running the following batch file on Windows x64:
:loop
java -XX:CompileOnly=RecursiveCall RecursiveCall
goto loop
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+119)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+119, mixed mode)
The bug looks similar toJDK-8152598, but that one was closed as a duplicate of non-public issue. So I'll leave this one in order to provide the publicly available description, initial analysis and the proposed solution (see comments), and also to track the status of the fix.
public class RecursiveCall {
static int depth;
public static void main(String[] args) {
try {
recursive();
} catch (StackOverflowError e) {
System.out.println(depth);
}
}
static void recursive() {
depth++;
recursive();
}
}
I can always reproduce it within a few minutes when running the following batch file on Windows x64:
:loop
java -XX:CompileOnly=RecursiveCall RecursiveCall
goto loop
java version "9-ea"
Java(TM) SE Runtime Environment (build 9-ea+119)
Java HotSpot(TM) 64-Bit Server VM (build 9-ea+119, mixed mode)
The bug looks similar to
- duplicates
-
JDK-8067946 StackYellowPages and StackRedPages have no effect on Windows
-
- Closed
-
- relates to
-
JDK-8152598 An unrecoverable stack overflow has occurred from compiled exceptions03101
-
- Closed
-