8252249: nsk/stress/stack/stack016.java fails with "Error: TEST_BUG: trickyRecursion() must throw an error anyway!"

Run test separately with both -Xint and -Xcomp to ensure thread stacks are similarly sized.

Reviewed-by: dholmes, coleenp
This commit is contained in:
Harold Seigel 2020-09-02 13:50:39 +00:00
parent 737ae7742a
commit f3597c4a54

@ -51,7 +51,8 @@
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp") * @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp")
* @library /vmTestbase * @library /vmTestbase
* @build nsk.share.Terminator * @build nsk.share.Terminator
* @run main/othervm/timeout=900 -Xss448K nsk.stress.stack.stack016 -eager * @run main/othervm/timeout=900 -Xint -Xss448K nsk.stress.stack.stack016 -eager
* @run main/othervm/timeout=900 -Xcomp -Xss448K nsk.stress.stack.stack016 -eager
*/ */
package nsk.stress.stack; package nsk.stress.stack;
@ -104,13 +105,14 @@ public class stack016 extends Thread {
// Measure recursive depth before stack overflow: // Measure recursive depth before stack overflow:
// //
int maxDepth = 0; int maxDepth = 0;
for (depthToTry = 0; ; depthToTry += STEP) for (depthToTry = 0; ; depthToTry += STEP) {
try { try {
trickyRecurse(depthToTry); trickyRecurse(depthToTry);
maxDepth = depthToTry; maxDepth = depthToTry;
} catch (Error error) { } catch (StackOverflowError | OutOfMemoryError ex) {
break; break;
} }
}
out.println("Maximal recursion depth: " + maxDepth); out.println("Maximal recursion depth: " + maxDepth);
// //
@ -123,25 +125,27 @@ public class stack016 extends Thread {
threads[i].depthToTry = RESERVE * maxDepth; threads[i].depthToTry = RESERVE * maxDepth;
threads[i].start(); threads[i].start();
} }
for (int i = 0; i < threads.length; i++) for (int i = 0; i < threads.length; i++) {
if (threads[i].isAlive()) if (threads[i].isAlive()) {
try { try {
threads[i].join(); threads[i].join();
} catch (InterruptedException exception) { } catch (InterruptedException exception) {
exception.printStackTrace(out); exception.printStackTrace(out);
return 2; return 2;
} }
}
}
// //
// Check if unexpected exceptions were thrown: // Check if unexpected exceptions were thrown:
// //
int exitCode = 0; int exitCode = 0;
for (int i = 0; i < threads.length; i++) for (int i = 0; i < threads.length; i++) {
if (threads[i].thrown != null) { if (threads[i].thrown != null) {
threads[i].thrown.printStackTrace(out); threads[i].thrown.printStackTrace(out);
exitCode = 2; exitCode = 2;
} }
}
if (exitCode != 0) if (exitCode != 0)
out.println("# TEST FAILED"); out.println("# TEST FAILED");
return exitCode; return exitCode;
@ -153,7 +157,7 @@ public class stack016 extends Thread {
private void trickyRecurse(int depth) { private void trickyRecurse(int depth) {
stackTop = depthToTry - depth; stackTop = depthToTry - depth;
if (depth > 0) if (depth > 0) {
try { try {
trickyRecurse(depth - 1); trickyRecurse(depth - 1);
} catch (Error error) { } catch (Error error) {
@ -171,6 +175,7 @@ public class stack016 extends Thread {
throw new Error("TEST_RFE: try deeper recursion!"); throw new Error("TEST_RFE: try deeper recursion!");
} }
}
} }
private static void recurse(int depth) { private static void recurse(int depth) {
@ -180,9 +185,10 @@ public class stack016 extends Thread {
public void run() { public void run() {
String threadName = Thread.currentThread().getName(); String threadName = Thread.currentThread().getName();
for (int i = 1; i <= CYCLES; i++) for (int i = 1; i <= CYCLES; i++) {
try { try {
display(threadName + ", iteration: " + i + "/" + CYCLES); display(threadName + ", iteration: " + i + "/" + CYCLES +
", depthToTry: " + depthToTry);
trickyRecurse(depthToTry); trickyRecurse(depthToTry);
throw new Error( throw new Error(
"TEST_BUG: trickyRecursion() must throw an error anyway!"); "TEST_BUG: trickyRecursion() must throw an error anyway!");
@ -198,5 +204,6 @@ public class stack016 extends Thread {
thrown = throwable; thrown = throwable;
break; break;
} }
}
} }
} }