mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
918b7828f1
The various Architecture::nextFrame implementations were not walking the stack correctly when a StackOverflowError was thrown. The throwStackOverflow thunk is called before the frame of the most recently called method has been fully created, and because tails=true builds use a different calling convention, we need to treat this situation carefully when building a stack trace or unwinding. Otherwise, we will skip past all the java frames to the next native frame, which is what was happening.
42 lines
851 B
Java
42 lines
851 B
Java
public class StackOverflow {
|
|
private static int add(int[] numbers, int offset, int length) {
|
|
if (length == 0) {
|
|
return 0;
|
|
} else {
|
|
return numbers[offset] + add(numbers, offset + 1, length - 1);
|
|
}
|
|
}
|
|
private static int add(int ... numbers) {
|
|
return add(numbers, 0, numbers.length);
|
|
}
|
|
|
|
private static int test1() {
|
|
add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
|
return test1() + 1;
|
|
}
|
|
|
|
private static int test2() {
|
|
return test3() + 1;
|
|
}
|
|
|
|
private static int test3() {
|
|
return test2() + 1;
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
try {
|
|
test1();
|
|
throw new RuntimeException();
|
|
} catch (StackOverflowError e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
try {
|
|
test2();
|
|
throw new RuntimeException();
|
|
} catch (StackOverflowError e) {
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
}
|