8326611: Clean up vmTestbase/nsk/stress/stack tests
Reviewed-by: coleenp, mseledtsov
This commit is contained in:
parent
5aae80304c
commit
972e81d1ad
@ -415,7 +415,8 @@ tier1_runtime = \
|
|||||||
-runtime/Unsafe/RangeCheck.java \
|
-runtime/Unsafe/RangeCheck.java \
|
||||||
sanity/ \
|
sanity/ \
|
||||||
-:tier1_runtime_appcds_exclude \
|
-:tier1_runtime_appcds_exclude \
|
||||||
-runtime/signal
|
-runtime/signal \
|
||||||
|
-runtime/stack
|
||||||
|
|
||||||
hotspot_cds = \
|
hotspot_cds = \
|
||||||
runtime/cds/ \
|
runtime/cds/ \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -52,25 +52,14 @@
|
|||||||
* 4302288 the second stack overflow causes Classic VM to exit on win32
|
* 4302288 the second stack overflow causes Classic VM to exit on win32
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack001
|
* @run main/othervm/timeout=900 Stack001
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack001 {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack001 {
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack001 test = new Stack001();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
stack001 test = new stack001();
|
|
||||||
test.recurse(0);
|
test.recurse(0);
|
||||||
out.println("Maximal depth: " + test.maxdepth);
|
System.out.println("Maximal depth: " + test.maxdepth);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int maxdepth;
|
private int maxdepth;
|
||||||
@ -79,13 +68,10 @@ public class stack001 {
|
|||||||
maxdepth = depth;
|
maxdepth = depth;
|
||||||
try {
|
try {
|
||||||
recurse(depth + 1);
|
recurse(depth + 1);
|
||||||
} catch (Error error) {
|
} catch (StackOverflowError | OutOfMemoryError e) {
|
||||||
if (!(error instanceof StackOverflowError) &&
|
if (maxdepth == depth) {
|
||||||
!(error instanceof OutOfMemoryError))
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
if (maxdepth == depth)
|
|
||||||
recurse(depth + 1);
|
recurse(depth + 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -53,24 +53,14 @@
|
|||||||
* 4302288 the second stack overflow causes Classic VM to exit on win32
|
* 4302288 the second stack overflow causes Classic VM to exit on win32
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack002
|
* @run main/othervm/timeout=900 Stack002
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack002 {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack002 {
|
|
||||||
static final long timeout = 10000; // 10 seconds
|
static final long timeout = 10000; // 10 seconds
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Tester tester = new Tester();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
Tester tester = new Tester(out);
|
|
||||||
Timer timer = new Timer(tester);
|
Timer timer = new Timer(tester);
|
||||||
timer.start();
|
timer.start();
|
||||||
tester.start();
|
tester.start();
|
||||||
@ -78,21 +68,18 @@ public class stack002 {
|
|||||||
try {
|
try {
|
||||||
timer.join();
|
timer.join();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace(out);
|
e.printStackTrace();
|
||||||
return 2;
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.println("Maximal depth: " + tester.maxdepth);
|
System.out.println("Maximal depth: " + tester.maxdepth);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Tester extends Thread {
|
private static class Tester extends Thread {
|
||||||
int maxdepth;
|
int maxdepth;
|
||||||
PrintStream out;
|
|
||||||
public volatile boolean stop;
|
public volatile boolean stop;
|
||||||
|
|
||||||
public Tester(PrintStream out) {
|
public Tester() {
|
||||||
this.out = out;
|
|
||||||
maxdepth = 0;
|
maxdepth = 0;
|
||||||
stop = false;
|
stop = false;
|
||||||
}
|
}
|
||||||
@ -108,10 +95,7 @@ public class stack002 {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
recurse(depth + 1);
|
recurse(depth + 1);
|
||||||
} catch (Error error) {
|
} catch (StackOverflowError | OutOfMemoryError e) {
|
||||||
if (!(error instanceof StackOverflowError) &&
|
|
||||||
!(error instanceof OutOfMemoryError))
|
|
||||||
throw error;
|
|
||||||
recurse(depth + 1);
|
recurse(depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,9 +113,9 @@ public class stack002 {
|
|||||||
started = System.currentTimeMillis();
|
started = System.currentTimeMillis();
|
||||||
while (System.currentTimeMillis() - started < timeout) {
|
while (System.currentTimeMillis() - started < timeout) {
|
||||||
try {
|
try {
|
||||||
this.sleep(1000);
|
Thread.sleep(1000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace(tester.out);
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,48 +47,37 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack003
|
* @run main/othervm/timeout=900 Stack003
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack003 {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack003 {
|
|
||||||
final static int ITERATIONS = 100;
|
final static int ITERATIONS = 100;
|
||||||
final static int INCREMENT = 100;
|
final static int INCREMENT = 100;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
int depth;
|
int depth;
|
||||||
for (depth = 1; ; depth += INCREMENT)
|
for (depth = 1; ; depth += INCREMENT) {
|
||||||
try {
|
try {
|
||||||
recurse(depth);
|
recurse(depth);
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + depth);
|
}
|
||||||
for (int i = 0; i < ITERATIONS; i++)
|
System.out.println("Max. depth: " + depth);
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
try {
|
try {
|
||||||
recurse(2 * depth);
|
recurse(2 * depth);
|
||||||
out.println("?");
|
System.out.println("?");
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// OK.
|
// OK.
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK.
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recurse(int depth) {
|
static void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -47,51 +47,38 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack004
|
* @run main/othervm/timeout=900 Stack004
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack004 {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack004 {
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack004 test = new Stack004();
|
||||||
System.exit(exitCode + 95);
|
test.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
public void doRun() {
|
||||||
stack004 test = new stack004();
|
|
||||||
int exitCode = test.doRun(args, out);
|
|
||||||
return exitCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int doRun(String args[], PrintStream out) {
|
|
||||||
int depth;
|
int depth;
|
||||||
for (depth = 100; ; depth += 100)
|
for (depth = 100; ; depth += 100) {
|
||||||
try {
|
try {
|
||||||
recurse(depth);
|
recurse(depth);
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + depth);
|
}
|
||||||
for (int i = 0; i < 100; i++)
|
System.out.println("Max. depth: " + depth);
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
try {
|
try {
|
||||||
recurse(2 * depth);
|
recurse(2 * depth);
|
||||||
out.println("?");
|
System.out.println("?");
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// OK.
|
// OK.
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK.
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final static void recurse(int depth) {
|
final static void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,46 +47,34 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack005
|
* @run main/othervm/timeout=900 Stack005
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack005 {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack005 {
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack005 test = new Stack005();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
stack005 test = new stack005();
|
|
||||||
int depth;
|
int depth;
|
||||||
for (depth = 100; ; depth += 100)
|
for (depth = 100; ; depth += 100) {
|
||||||
try {
|
try {
|
||||||
test.recurse(depth);
|
test.recurse(depth);
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError soe) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + depth);
|
}
|
||||||
for (int i = 0; i < 100; i++)
|
System.out.println("Max. depth: " + depth);
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
try {
|
try {
|
||||||
test.recurse(2 * depth);
|
test.recurse(2 * depth);
|
||||||
out.println("?");
|
System.out.println("?");
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// OK.
|
// OK.
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK.
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final void recurse(int depth) {
|
final void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,50 +47,38 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack006
|
* @run main/othervm/timeout=900 Stack006
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack006 implements Stack006i {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack006 implements stack006i {
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack006i test = new Stack006();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
stack006i test = new stack006();
|
|
||||||
int depth;
|
int depth;
|
||||||
for (depth = 100; ; depth += 100)
|
for (depth = 100; ; depth += 100) {
|
||||||
try {
|
try {
|
||||||
test.recurse(depth);
|
test.recurse(depth);
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + depth);
|
}
|
||||||
for (int i = 0; i < 100; i++)
|
System.out.println("Max. depth: " + depth);
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
try {
|
try {
|
||||||
test.recurse(2 * depth);
|
test.recurse(2 * depth);
|
||||||
out.println("?");
|
System.out.println("?");
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// OK.
|
// OK.
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK.
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recurse(int depth) {
|
public void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface stack006i {
|
interface Stack006i {
|
||||||
void recurse(int depth);
|
void recurse(int depth);
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -46,53 +46,41 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack007
|
* @run main/othervm/timeout=900 Stack007
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack007 implements Stack007i {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack007 implements stack007i {
|
|
||||||
final static int ITERATIONS = 1000;
|
final static int ITERATIONS = 1000;
|
||||||
final static int INCREMENT = 100;
|
final static int INCREMENT = 100;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack007i test = new Stack007();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
stack007i test = new stack007();
|
|
||||||
int depth;
|
int depth;
|
||||||
for (depth = 100; ; depth += INCREMENT)
|
for (depth = 100; ; depth += INCREMENT) {
|
||||||
try {
|
try {
|
||||||
test.recurse(depth);
|
test.recurse(depth);
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + depth);
|
}
|
||||||
for (int i = 0; i < ITERATIONS; i++)
|
System.out.println("Max. depth: " + depth);
|
||||||
|
for (int i = 0; i < ITERATIONS; i++) {
|
||||||
try {
|
try {
|
||||||
test.recurse(10 * depth);
|
test.recurse(10 * depth);
|
||||||
out.println("?");
|
System.out.println("?");
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// OK.
|
// OK.
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK.
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void recurse(int depth) {
|
public synchronized void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface stack007i {
|
interface Stack007i {
|
||||||
void recurse(int depth);
|
void recurse(int depth);
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,28 +48,19 @@
|
|||||||
* Making it bigger could cause timeouts on other platform.
|
* Making it bigger could cause timeouts on other platform.
|
||||||
*
|
*
|
||||||
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
||||||
* @run main/othervm/timeout=900 -Xss200K nsk.stress.stack.stack008
|
* @run main/othervm/timeout=900 -Xss200K Stack008
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class stack008 {
|
public class Stack008 {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
int depth;
|
int depth;
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
for (depth = 100; ; depth += 100)
|
for (depth = 100; ; depth += 100) {
|
||||||
try {
|
try {
|
||||||
invokeRecurse(depth);
|
invokeRecurse(depth);
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
@ -77,30 +68,27 @@ public class stack008 {
|
|||||||
if ((target instanceof StackOverflowError) ||
|
if ((target instanceof StackOverflowError) ||
|
||||||
(target instanceof OutOfMemoryError))
|
(target instanceof OutOfMemoryError))
|
||||||
break; // OK.
|
break; // OK.
|
||||||
target.printStackTrace(out);
|
target.printStackTrace();
|
||||||
if (target instanceof ThreadDeath)
|
throw new RuntimeException(exception);
|
||||||
throw (ThreadDeath) target;
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + depth);
|
}
|
||||||
|
System.out.println("Max. depth: " + depth);
|
||||||
//
|
//
|
||||||
// Provoke stack overflow multiple times:
|
// Provoke stack overflow multiple times:
|
||||||
//
|
//
|
||||||
for (int i = 0; i < 100; i++)
|
for (int i = 0; i < 100; i++) {
|
||||||
try {
|
try {
|
||||||
invokeRecurse(2 * depth);
|
invokeRecurse(2 * depth);
|
||||||
// out.println("?");
|
// System.out.println("?");
|
||||||
} catch (Throwable exception) {
|
} catch (Throwable exception) {
|
||||||
Throwable target = getTargetException(exception);
|
Throwable target = getTargetException(exception);
|
||||||
if ((target instanceof StackOverflowError) ||
|
if ((target instanceof StackOverflowError) ||
|
||||||
(target instanceof OutOfMemoryError))
|
(target instanceof OutOfMemoryError))
|
||||||
continue; // OK.
|
continue; // OK.
|
||||||
target.printStackTrace(out);
|
target.printStackTrace();
|
||||||
if (target instanceof ThreadDeath)
|
throw new RuntimeException(exception);
|
||||||
throw (ThreadDeath) target;
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Throwable getTargetException(Throwable exception) {
|
private static Throwable getTargetException(Throwable exception) {
|
||||||
@ -118,7 +106,7 @@ public class stack008 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static Method method = null;
|
static Method method = null;
|
||||||
static stack008 instance = null;
|
static Stack008 instance = null;
|
||||||
static Object params[] = null;
|
static Object params[] = null;
|
||||||
|
|
||||||
private static void invokeRecurse(int depth) throws Exception {
|
private static void invokeRecurse(int depth) throws Exception {
|
||||||
@ -126,8 +114,8 @@ public class stack008 {
|
|||||||
//
|
//
|
||||||
// Optimization trick: allocate once, use everywhere.
|
// Optimization trick: allocate once, use everywhere.
|
||||||
//
|
//
|
||||||
instance = new stack008();
|
instance = new Stack008();
|
||||||
method = stack008.class.getMethod("recurse");
|
method = Stack008.class.getMethod("recurse");
|
||||||
params = new Object[]{};
|
params = new Object[]{};
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
@ -140,10 +128,11 @@ public class stack008 {
|
|||||||
int depth = 0;
|
int depth = 0;
|
||||||
|
|
||||||
public void recurse() throws Exception {
|
public void recurse() throws Exception {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
//
|
//
|
||||||
// Self-invoke via reflection:
|
// Self-invoke via reflection:
|
||||||
//
|
//
|
||||||
invokeRecurse(depth - 1);
|
invokeRecurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,49 +47,32 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack009
|
* @run main/othervm/timeout=900 Stack009
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack009 {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack009 {
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
for (int depth = 100; ; depth += 100) {
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
for (int depth = 100; ; depth += 100)
|
|
||||||
try {
|
try {
|
||||||
recurse(depth);
|
recurse(depth);
|
||||||
} catch (Error error1) {
|
} catch (StackOverflowError | OutOfMemoryError error1) {
|
||||||
if (!(error1 instanceof StackOverflowError) &&
|
|
||||||
!(error1 instanceof OutOfMemoryError))
|
|
||||||
throw error1;
|
|
||||||
|
|
||||||
out.println("Max. depth: " + depth);
|
System.out.println("Max. depth: " + depth);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recurse(10 * depth);
|
recurse(10 * depth);
|
||||||
out.println("?");
|
System.out.println("?");
|
||||||
} catch (Error error2) {
|
} catch (StackOverflowError | OutOfMemoryError error2) {
|
||||||
if (!(error2 instanceof StackOverflowError) &&
|
// ignore
|
||||||
!(error2 instanceof OutOfMemoryError))
|
|
||||||
throw error2;
|
|
||||||
|
|
||||||
// Stack overflow is OK here.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recurse(int depth) {
|
static void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,99 +47,82 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack010
|
* @run main/othervm/timeout=900 Stack010
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack010 extends Thread {
|
||||||
|
final static int THREADS = 1;
|
||||||
|
final static int CYCLES = 1;
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack010 extends Thread {
|
|
||||||
final static int THREADS = 10;
|
|
||||||
final static int CYCLES = 10;
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
int maxDepth = 0;
|
int maxDepth = 0;
|
||||||
for (int depth = 10; ; depth += 10)
|
for (int depth = 10; ; depth += 10) {
|
||||||
try {
|
try {
|
||||||
recurse(depth);
|
recurse(depth);
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + maxDepth);
|
}
|
||||||
|
System.out.println("Max. depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Execute multiple threads repeatedly provoking stack overflows:
|
// Execute multiple threads repeatedly provoking stack overflows:
|
||||||
//
|
//
|
||||||
stack010 threads[] = new stack010[THREADS];
|
Stack010 threads[] = new Stack010[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack010();
|
threads[i] = new Stack010();
|
||||||
threads[i].depthToTry = 10 * maxDepth;
|
threads[i].depthToTry = 100 * 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);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Check if unexpected exceptions were not thrown:
|
// Check if unexpected exceptions were not thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int depthToTry = 0;
|
int depthToTry = 0;
|
||||||
Throwable thrown = null;
|
Throwable thrown = null;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int i = 0; i < CYCLES; i++)
|
for (int i = 0; i < CYCLES; i++) {
|
||||||
try {
|
try {
|
||||||
|
System.out.println("depth = " +depthToTry);
|
||||||
recurse(depthToTry);
|
recurse(depthToTry);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"TEST_RFE: no stack overflow thrown" +
|
"TEST_RFE: no stack overflow thrown" +
|
||||||
", need to try deeper recursion?");
|
", need to try deeper recursion?");
|
||||||
|
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK: out of memory may indacate stack overflow.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
// It isn't OK!
|
// It isn't OK!
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void recurse(int depth) {
|
static void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,99 +47,81 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack011
|
* @run main/othervm/timeout=900 Stack011
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack011 extends Thread {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack011 extends Thread {
|
|
||||||
final static int THREADS = 10;
|
final static int THREADS = 10;
|
||||||
final static int CYCLES = 10;
|
final static int CYCLES = 10;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
int maxDepth = 0;
|
int maxDepth = 0;
|
||||||
for (int depth = 10; ; depth += 10)
|
for (int depth = 10; ; depth += 10) {
|
||||||
try {
|
try {
|
||||||
recurse(depth);
|
recurse(depth);
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError soe) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + maxDepth);
|
}
|
||||||
|
System.out.println("Max. depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Execute multiple threads repeatedly provoking stack overflows:
|
// Execute multiple threads repeatedly provoking stack overflows:
|
||||||
//
|
//
|
||||||
stack011 threads[] = new stack011[THREADS];
|
Stack011 threads[] = new Stack011[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack011();
|
threads[i] = new Stack011();
|
||||||
threads[i].depthToTry = 10 * maxDepth;
|
threads[i].depthToTry = 10 * 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);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Check if unexpected exceptions were not thrown:
|
// Check if unexpected exceptions were not thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int depthToTry = 0;
|
int depthToTry = 0;
|
||||||
Throwable thrown = null;
|
Throwable thrown = null;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int i = 0; i < CYCLES; i++)
|
for (int i = 0; i < CYCLES; i++) {
|
||||||
try {
|
try {
|
||||||
recurse(depthToTry);
|
recurse(depthToTry);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"TEST_RFE: no stack overflow thrown" +
|
"TEST_RFE: no stack overflow thrown" +
|
||||||
", need to try deeper recursion?");
|
", need to try deeper recursion?");
|
||||||
|
|
||||||
} catch (StackOverflowError error) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK: recursion may result in memory lack.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
// It isn't OK!
|
// It isn't OK!
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final static void recurse(int depth) {
|
final static void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,100 +48,82 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack012
|
* @run main/othervm/timeout=900 Stack012
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack012 extends Thread {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack012 extends Thread {
|
|
||||||
final static int THREADS = 10;
|
final static int THREADS = 10;
|
||||||
final static int CYCLES = 10;
|
final static int CYCLES = 10;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack012 test = new Stack012();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
stack012 test = new stack012();
|
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
int maxDepth = 0;
|
int maxDepth = 0;
|
||||||
for (int depth = 10; ; depth += 10)
|
for (int depth = 10; ; depth += 10) {
|
||||||
try {
|
try {
|
||||||
test.recurse(depth);
|
test.recurse(depth);
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + maxDepth);
|
}
|
||||||
|
System.out.println("Max. depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Execute multiple threads repeatedly provoking stack overflows:
|
// Execute multiple threads repeatedly provoking stack overflows:
|
||||||
//
|
//
|
||||||
stack012 threads[] = new stack012[THREADS];
|
Stack012 threads[] = new Stack012[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack012();
|
threads[i] = new Stack012();
|
||||||
threads[i].depthToTry = 10 * maxDepth;
|
threads[i].depthToTry = 10 * 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);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Check if unexpected exceptions were not thrown:
|
// Check if unexpected exceptions were not thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int depthToTry = 0;
|
int depthToTry = 0;
|
||||||
Throwable thrown = null;
|
Throwable thrown = null;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int i = 0; i < CYCLES; i++)
|
for (int i = 0; i < CYCLES; i++) {
|
||||||
try {
|
try {
|
||||||
this.recurse(depthToTry);
|
this.recurse(depthToTry);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"TEST_RFE: no stack overflow thrown" +
|
"TEST_RFE: no stack overflow thrown" +
|
||||||
", need to try deeper recursion?");
|
", need to try deeper recursion?");
|
||||||
|
|
||||||
} catch (StackOverflowError error) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK: invocation may result in out of memory.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
// It isn't OK!
|
// It isn't OK!
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final void recurse(int depth) {
|
final void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -47,81 +47,67 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack013
|
* @run main/othervm/timeout=900 Stack013
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack013 extends Stack013i {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack013 extends stack013i {
|
|
||||||
final static int THREADS = 10;
|
final static int THREADS = 10;
|
||||||
final static int CYCLES = 10;
|
final static int CYCLES = 10;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack013i test = new Stack013();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
stack013i test = new stack013();
|
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
int maxDepth = 0;
|
int maxDepth = 0;
|
||||||
for (int depth = 10; ; depth += 10)
|
for (int depth = 10; ; depth += 10) {
|
||||||
try {
|
try {
|
||||||
test.recurse(depth);
|
test.recurse(depth);
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + maxDepth);
|
}
|
||||||
|
System.out.println("Max. depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Execute multiple threads repeatedly provoking stack overflows:
|
// Execute multiple threads repeatedly provoking stack overflows:
|
||||||
//
|
//
|
||||||
stack013i threads[] = new stack013i[THREADS];
|
Stack013i threads[] = new Stack013i[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack013();
|
threads[i] = new Stack013();
|
||||||
threads[i].depthToTry = 10 * maxDepth;
|
threads[i].depthToTry = 10 * maxDepth;
|
||||||
threads[i].cycles = CYCLES;
|
threads[i].cycles = CYCLES;
|
||||||
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);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Check if unexpected exceptions were thrown:
|
// Check if unexpected exceptions were thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void recurse(int depth) {
|
void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class stack013i extends Thread {
|
abstract class Stack013i extends Thread {
|
||||||
//
|
//
|
||||||
// Pure virtual method:
|
// Pure virtual method:
|
||||||
//
|
//
|
||||||
@ -135,24 +121,20 @@ abstract class stack013i extends Thread {
|
|||||||
//
|
//
|
||||||
// Provoke multiple stack overflows:
|
// Provoke multiple stack overflows:
|
||||||
//
|
//
|
||||||
for (int i = 0; i < cycles; i++)
|
for (int i = 0; i < cycles; i++) {
|
||||||
try {
|
try {
|
||||||
recurse(depthToTry);
|
recurse(depthToTry);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"TEST_RFE: no stack overflow thrown" +
|
"TEST_RFE: no stack overflow thrown" +
|
||||||
", need to try deeper recursion?");
|
", need to try deeper recursion?");
|
||||||
|
|
||||||
} catch (StackOverflowError error) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK: out of memory is eligible here.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
// It isn't OK!
|
// It isn't OK!
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -50,81 +50,67 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack014
|
* @run main/othervm/timeout=900 Stack014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack014 extends Stack014i {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack014 extends stack014i {
|
|
||||||
final static int THREADS = 10;
|
final static int THREADS = 10;
|
||||||
final static int CYCLES = 10;
|
final static int CYCLES = 10;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack014i test = new Stack014();
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
stack014i test = new stack014();
|
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
int maxDepth = 0;
|
int maxDepth = 0;
|
||||||
for (int depth = 10; ; depth += 10)
|
for (int depth = 10; ; depth += 10) {
|
||||||
try {
|
try {
|
||||||
test.recurse(depth);
|
test.recurse(depth);
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + maxDepth);
|
}
|
||||||
|
System.out.println("Max. depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Execute multiple threads repeatedly provoking stack overflows:
|
// Execute multiple threads repeatedly provoking stack overflows:
|
||||||
//
|
//
|
||||||
stack014i threads[] = new stack014i[THREADS];
|
Stack014i threads[] = new Stack014i[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack014();
|
threads[i] = new Stack014();
|
||||||
threads[i].depthToTry = 10 * maxDepth;
|
threads[i].depthToTry = 10 * maxDepth;
|
||||||
threads[i].cycles = CYCLES;
|
threads[i].cycles = CYCLES;
|
||||||
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);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Check if unexpected exceptions were thrown:
|
// Check if unexpected exceptions were thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void recurse(int depth) {
|
synchronized void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class stack014i extends Thread {
|
abstract class Stack014i extends Thread {
|
||||||
//
|
//
|
||||||
// Pure virtual method:
|
// Pure virtual method:
|
||||||
//
|
//
|
||||||
@ -138,24 +124,20 @@ abstract class stack014i extends Thread {
|
|||||||
//
|
//
|
||||||
// Provoke multiple stack overflows:
|
// Provoke multiple stack overflows:
|
||||||
//
|
//
|
||||||
for (int i = 0; i < cycles; i++)
|
for (int i = 0; i < cycles; i++) {
|
||||||
try {
|
try {
|
||||||
recurse(depthToTry);
|
recurse(depthToTry);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"TEST_RFE: no stack overflow thrown" +
|
"TEST_RFE: no stack overflow thrown" +
|
||||||
", need to try deeper recursion?");
|
", need to try deeper recursion?");
|
||||||
|
|
||||||
} catch (StackOverflowError error) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK: if there is no memory for stack expansion.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
// It isn't OK!
|
// It isn't OK!
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -48,88 +48,74 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires vm.opt.DeoptimizeALot != true
|
* @requires vm.opt.DeoptimizeALot != true
|
||||||
* @run main/othervm/timeout=900 nsk.stress.stack.stack015
|
* @run main/othervm/timeout=900 Stack015
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack015 extends Stack015i {
|
||||||
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack015 extends stack015i {
|
|
||||||
final static int THREADS = 10;
|
final static int THREADS = 10;
|
||||||
final static int CYCLES = 10;
|
final static int CYCLES = 10;
|
||||||
final static int STEP = 10;
|
final static int STEP = 10;
|
||||||
final static int RESERVE = 10;
|
final static int RESERVE = 10;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
//
|
//
|
||||||
// The test will invoke the particular stack015.recurse()
|
// The test will invoke the particular Stack015.recurse()
|
||||||
// method via abstract test.recurse() invocations.
|
// method via abstract test.recurse() invocations.
|
||||||
//
|
//
|
||||||
stack015i test = new stack015();
|
Stack015i test = new Stack015();
|
||||||
stack015i.test = test;
|
Stack015i.test = test;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
int maxDepth = 0;
|
int maxDepth = 0;
|
||||||
for (int depth = 0; ; depth += STEP)
|
for (int depth = 0; ; depth += STEP) {
|
||||||
try {
|
try {
|
||||||
test.recurse(depth);
|
test.recurse(depth);
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
break;
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
out.println("Max. depth: " + maxDepth);
|
}
|
||||||
|
System.out.println("Max. depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Execute multiple threads repeatedly provoking stack overflows:
|
// Execute multiple threads repeatedly provoking stack overflows:
|
||||||
//
|
//
|
||||||
stack015i threads[] = new stack015i[THREADS];
|
Stack015i threads[] = new Stack015i[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack015();
|
threads[i] = new Stack015();
|
||||||
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);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Check if unexpected exceptions were thrown:
|
// Check if unexpected exceptions were thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void syncRecurse(int depth) {
|
synchronized void syncRecurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
syncRecurse(depth - 1);
|
syncRecurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class stack015i extends Thread {
|
abstract class Stack015i extends Thread {
|
||||||
//
|
//
|
||||||
// Pure virtual method:
|
// Pure virtual method:
|
||||||
//
|
//
|
||||||
@ -139,24 +125,25 @@ abstract class stack015i extends Thread {
|
|||||||
//
|
//
|
||||||
// Stack overflow must occur here:
|
// Stack overflow must occur here:
|
||||||
//
|
//
|
||||||
syncRecurse(stack015.STEP);
|
syncRecurse(Stack015.STEP);
|
||||||
//
|
//
|
||||||
// If no stack overflow occured, try again with deeper stack:
|
// If no stack overflow occured, try again with deeper stack:
|
||||||
//
|
//
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Throwable thrown = null;
|
Throwable thrown = null;
|
||||||
int depthToTry;
|
int depthToTry;
|
||||||
|
|
||||||
static stack015i test;
|
static Stack015i test;
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
//
|
//
|
||||||
// Provoke multiple stack overflows:
|
// Provoke multiple stack overflows:
|
||||||
//
|
//
|
||||||
for (int i = 0; i < stack015.CYCLES; i++)
|
for (int i = 0; i < Stack015.CYCLES; i++) {
|
||||||
try {
|
try {
|
||||||
//
|
//
|
||||||
// All threads invoke the same synchronized method:
|
// All threads invoke the same synchronized method:
|
||||||
@ -167,17 +154,13 @@ abstract class stack015i extends Thread {
|
|||||||
"TEST_RFE: no stack overflow thrown" +
|
"TEST_RFE: no stack overflow thrown" +
|
||||||
", need to try deeper recursion?");
|
", need to try deeper recursion?");
|
||||||
|
|
||||||
} catch (StackOverflowError error) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK: there may be no memory for stack expansion.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
// It isn't OK!
|
// It isn't OK!
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -49,21 +49,12 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp")
|
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp")
|
||||||
* @library /vmTestbase
|
* @run main/othervm/timeout=900 -Xint -Xss448K Stack016
|
||||||
* @build nsk.share.Terminator
|
* @run main/othervm/timeout=900 -Xcomp -Xss448K Stack016
|
||||||
* @run main/othervm/timeout=900 -Xint -Xss448K nsk.stress.stack.stack016 -eager
|
* @run main/othervm/timeout=900 -Xcomp -XX:-TieredCompilation -Xss448K Stack016
|
||||||
* @run main/othervm/timeout=900 -Xcomp -Xss448K nsk.stress.stack.stack016 -eager
|
|
||||||
* @run main/othervm/timeout=900 -Xcomp -XX:-TieredCompilation -Xss448K nsk.stress.stack.stack016 -eager
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack016 extends Thread {
|
||||||
|
|
||||||
|
|
||||||
import nsk.share.Terminator;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack016 extends Thread {
|
|
||||||
private final static int THREADS = 10;
|
private final static int THREADS = 10;
|
||||||
private final static int CYCLES = 10;
|
private final static int CYCLES = 10;
|
||||||
private final static int STEP = 10;
|
private final static int STEP = 10;
|
||||||
@ -71,37 +62,11 @@ public class stack016 extends Thread {
|
|||||||
private final static int PROBES = STEP * RESERVE;
|
private final static int PROBES = STEP * RESERVE;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack016 test = new Stack016();
|
||||||
System.exit(exitCode + 95);
|
test.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
private void doRun() {
|
||||||
verbose = false;
|
|
||||||
boolean eager = false;
|
|
||||||
for (int i = 0; i < args.length; i++)
|
|
||||||
if (args[i].toLowerCase().equals("-verbose"))
|
|
||||||
verbose = true;
|
|
||||||
else if (args[i].toLowerCase().equals("-eager"))
|
|
||||||
eager = true;
|
|
||||||
if (!eager)
|
|
||||||
Terminator.appoint(Terminator.parseAppointment(args));
|
|
||||||
stack016.out = out;
|
|
||||||
stack016 test = new stack016();
|
|
||||||
return test.doRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean verbose;
|
|
||||||
private static PrintStream out;
|
|
||||||
|
|
||||||
private void display(Object message) {
|
|
||||||
if (!verbose)
|
|
||||||
return;
|
|
||||||
synchronized (out) {
|
|
||||||
out.println(message.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int doRun() {
|
|
||||||
//
|
//
|
||||||
// Measure recursive depth before stack overflow:
|
// Measure recursive depth before stack overflow:
|
||||||
//
|
//
|
||||||
@ -114,14 +79,14 @@ public class stack016 extends Thread {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.println("Maximal recursion depth: " + maxDepth);
|
System.out.println("Maximal recursion depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Run the tested threads:
|
// Run the tested threads:
|
||||||
//
|
//
|
||||||
stack016 threads[] = new stack016[THREADS];
|
Stack016 threads[] = new Stack016[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack016();
|
threads[i] = new Stack016();
|
||||||
threads[i].setName("Thread: " + (i + 1) + "/" + THREADS);
|
threads[i].setName("Thread: " + (i + 1) + "/" + THREADS);
|
||||||
threads[i].depthToTry = RESERVE * maxDepth;
|
threads[i].depthToTry = RESERVE * maxDepth;
|
||||||
threads[i].start();
|
threads[i].start();
|
||||||
@ -131,8 +96,7 @@ public class stack016 extends Thread {
|
|||||||
try {
|
try {
|
||||||
threads[i].join();
|
threads[i].join();
|
||||||
} catch (InterruptedException exception) {
|
} catch (InterruptedException exception) {
|
||||||
exception.printStackTrace(out);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,16 +104,12 @@ public class stack016 extends Thread {
|
|||||||
//
|
//
|
||||||
// Check if unexpected exceptions were thrown:
|
// Check if unexpected exceptions were thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int stackTop = 0;
|
private int stackTop = 0;
|
||||||
@ -161,11 +121,7 @@ public class stack016 extends Thread {
|
|||||||
if (depth > 0) {
|
if (depth > 0) {
|
||||||
try {
|
try {
|
||||||
trickyRecurse(depth - 1);
|
trickyRecurse(depth - 1);
|
||||||
} catch (Error error) {
|
} catch (StackOverflowError | OutOfMemoryError error) {
|
||||||
if (!(error instanceof StackOverflowError) &&
|
|
||||||
!(error instanceof OutOfMemoryError))
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Provoke more stack overflow,
|
// Provoke more stack overflow,
|
||||||
// if current stack is deep enough:
|
// if current stack is deep enough:
|
||||||
@ -180,28 +136,24 @@ public class stack016 extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void recurse(int depth) {
|
private static void recurse(int depth) {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
recurse(depth - 1);
|
recurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 +
|
System.out.println(threadName + ", iteration: " + i + "/" + CYCLES +
|
||||||
", depthToTry: " + depthToTry);
|
", 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!");
|
||||||
|
|
||||||
} catch (StackOverflowError error) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK, if there is no memory for stack expansion.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
@ -42,99 +42,59 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
||||||
* @library /vmTestbase
|
* @run main/othervm/timeout=900 -Xss220K Stack017
|
||||||
* @build nsk.share.Terminator
|
|
||||||
* @run main/othervm/timeout=900 -Xss220K nsk.stress.stack.stack017 -eager
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack017 extends Thread {
|
||||||
|
|
||||||
|
|
||||||
import nsk.share.Terminator;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack017 extends Thread {
|
|
||||||
private final static int THREADS = 10;
|
private final static int THREADS = 10;
|
||||||
private final static int CYCLES = 10;
|
private final static int CYCLES = 10;
|
||||||
private final static int PROBES = 100;
|
private final static int PROBES = 100;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack017 test = new Stack017();
|
||||||
System.exit(exitCode + 95);
|
test.doRun();
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
verbose = false;
|
|
||||||
boolean eager = false;
|
|
||||||
for (int i = 0; i < args.length; i++)
|
|
||||||
if (args[i].toLowerCase().equals("-verbose"))
|
|
||||||
verbose = true;
|
|
||||||
else if (args[i].toLowerCase().equals("-eager"))
|
|
||||||
eager = true;
|
|
||||||
if (!eager)
|
|
||||||
Terminator.appoint(Terminator.parseAppointment(args));
|
|
||||||
stack017.out = out;
|
|
||||||
stack017 test = new stack017();
|
|
||||||
return test.doRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean verbose;
|
|
||||||
private static PrintStream out;
|
|
||||||
|
|
||||||
private void display(Object message) {
|
|
||||||
if (!verbose)
|
|
||||||
return;
|
|
||||||
synchronized (out) {
|
|
||||||
out.println(message.toString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int depthToTry;
|
private static int depthToTry;
|
||||||
|
|
||||||
private int doRun() {
|
private void doRun() {
|
||||||
//
|
//
|
||||||
// Measure recursive depth before stack overflow:
|
// Measure recursive depth before stack overflow:
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
recurse(0);
|
recurse(0);
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
}
|
}
|
||||||
out.println("Maximal recursion depth: " + maxDepth);
|
System.out.println("Maximal recursion depth: " + maxDepth);
|
||||||
depthToTry = maxDepth;
|
depthToTry = maxDepth;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Run the tested threads:
|
// Run the tested threads:
|
||||||
//
|
//
|
||||||
stack017 threads[] = new stack017[THREADS];
|
Stack017 threads[] = new Stack017[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack017();
|
threads[i] = new Stack017();
|
||||||
threads[i].setName("Thread: " + (i + 1) + "/" + THREADS);
|
threads[i].setName("Thread: " + (i + 1) + "/" + THREADS);
|
||||||
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);
|
throw new RuntimeException(exception);
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//
|
//
|
||||||
// Check if unexpected exceptions were thrown:
|
// Check if unexpected exceptions were thrown:
|
||||||
//
|
//
|
||||||
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();
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int maxDepth = 0;
|
private int maxDepth = 0;
|
||||||
@ -148,11 +108,7 @@ public class stack017 extends Thread {
|
|||||||
try {
|
try {
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
trickyRecurse(depth + 1);
|
trickyRecurse(depth + 1);
|
||||||
} catch (Error error) {
|
} catch (StackOverflowError | OutOfMemoryError error) {
|
||||||
if (!(error instanceof StackOverflowError) &&
|
|
||||||
!(error instanceof OutOfMemoryError))
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Stack problem caught: provoke it again,
|
// Stack problem caught: provoke it again,
|
||||||
// if current stack is enough deep:
|
// if current stack is enough deep:
|
||||||
@ -169,19 +125,14 @@ public class stack017 extends Thread {
|
|||||||
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);
|
System.out.println(threadName + ", iteration: " + i + "/" + CYCLES);
|
||||||
trickyRecurse(0);
|
trickyRecurse(0);
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
"TEST_BUG: stack overflow was expected!");
|
"TEST_BUG: stack overflow was expected!");
|
||||||
|
|
||||||
} catch (StackOverflowError oome) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
// It's OK: stack overflow was expected.
|
// It's OK
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// Also OK, if there is no memory for stack expansion.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
// It isn't OK!
|
// It isn't OK!
|
||||||
thrown = throwable;
|
thrown = throwable;
|
||||||
break;
|
break;
|
@ -47,58 +47,24 @@
|
|||||||
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
* 4366625 (P4/S4) multiple stack overflow causes HS crash
|
||||||
*
|
*
|
||||||
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
||||||
* @library /vmTestbase
|
* @run main/othervm/timeout=900 -Xss220K Stack018
|
||||||
* @build nsk.share.Terminator
|
|
||||||
* @run main/othervm/timeout=900 -Xss220K nsk.stress.stack.stack018 -eager
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
|
||||||
|
|
||||||
|
|
||||||
import nsk.share.Terminator;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
public class stack018 extends Thread {
|
public class Stack018 extends Thread {
|
||||||
private final static int THREADS = 10;
|
private final static int THREADS = 10;
|
||||||
private final static int CYCLES = 10;
|
private final static int CYCLES = 10;
|
||||||
private final static int STEP = 100;
|
private final static int STEP = 100;
|
||||||
private final static int RESERVE = 100;
|
private final static int RESERVE = 100;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
Stack018 test = new Stack018();
|
||||||
System.exit(exitCode + 95);
|
test.doRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
private void doRun() {
|
||||||
verbose = false;
|
|
||||||
boolean eager = false;
|
|
||||||
for (int i = 0; i < args.length; i++)
|
|
||||||
if (args[i].toLowerCase().equals("-verbose"))
|
|
||||||
verbose = true;
|
|
||||||
else if (args[i].toLowerCase().equals("-eager"))
|
|
||||||
eager = true;
|
|
||||||
if (!eager)
|
|
||||||
Terminator.appoint(Terminator.parseAppointment(args));
|
|
||||||
stack018.out = out;
|
|
||||||
stack018 test = new stack018();
|
|
||||||
return test.doRun();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean verbose;
|
|
||||||
private static PrintStream out;
|
|
||||||
|
|
||||||
private void display(Object message) {
|
|
||||||
if (!verbose)
|
|
||||||
return;
|
|
||||||
synchronized (out) {
|
|
||||||
out.println(message.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int doRun() {
|
|
||||||
//
|
//
|
||||||
// Measure maximal recursion depth until stack overflow:
|
// Measure maximal recursion depth until stack overflow:
|
||||||
//
|
//
|
||||||
@ -112,10 +78,8 @@ public class stack018 extends Thread {
|
|||||||
if ((target instanceof StackOverflowError) ||
|
if ((target instanceof StackOverflowError) ||
|
||||||
(target instanceof OutOfMemoryError))
|
(target instanceof OutOfMemoryError))
|
||||||
break; // OK.
|
break; // OK.
|
||||||
target.printStackTrace(out);
|
target.printStackTrace();
|
||||||
if (target instanceof ThreadDeath)
|
throw new RuntimeException(exception);
|
||||||
throw (ThreadDeath) target;
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,41 +87,38 @@ public class stack018 extends Thread {
|
|||||||
// The depth STEP was enough to cause StackOverflowError or OutOfMemoryError.
|
// The depth STEP was enough to cause StackOverflowError or OutOfMemoryError.
|
||||||
maxDepth = STEP;
|
maxDepth = STEP;
|
||||||
}
|
}
|
||||||
out.println("Maximal recursion depth: " + maxDepth);
|
System.out.println("Maximal recursion depth: " + maxDepth);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Run the tested threads:
|
// Run the tested threads:
|
||||||
//
|
//
|
||||||
stack018 threads[] = new stack018[THREADS];
|
Stack018 threads[] = new Stack018[THREADS];
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
threads[i] = new stack018();
|
threads[i] = new Stack018();
|
||||||
threads[i].setName("Thread: " + (i + 1) + "/" + THREADS);
|
threads[i].setName("Thread: " + (i + 1) + "/" + THREADS);
|
||||||
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);
|
throw new RuntimeException(exception);
|
||||||
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) {
|
||||||
out.println("# " + threads[i].getName()
|
System.out.println("# " + threads[i].getName()
|
||||||
+ ": " + threads[i].thrown);
|
+ ": " + threads[i].thrown);
|
||||||
exitCode = 2;
|
throw new RuntimeException("Exception in the thread " + threads[i], threads[i].thrown);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (exitCode != 0)
|
|
||||||
out.println("# TEST FAILED");
|
|
||||||
return exitCode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int depthToTry = 0;
|
private int depthToTry = 0;
|
||||||
@ -167,7 +128,7 @@ public class stack018 extends Thread {
|
|||||||
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);
|
System.out.println(threadName + ", iteration: " + i + "/" + CYCLES);
|
||||||
invokeRecurse(depthToTry);
|
invokeRecurse(depthToTry);
|
||||||
throw new Error("TEST_RFE: try deeper invocations!");
|
throw new Error("TEST_RFE: try deeper invocations!");
|
||||||
|
|
||||||
@ -176,8 +137,6 @@ public class stack018 extends Thread {
|
|||||||
if ((target instanceof StackOverflowError) ||
|
if ((target instanceof StackOverflowError) ||
|
||||||
(target instanceof OutOfMemoryError))
|
(target instanceof OutOfMemoryError))
|
||||||
continue; // OK.
|
continue; // OK.
|
||||||
if (target instanceof ThreadDeath)
|
|
||||||
throw (ThreadDeath) target;
|
|
||||||
thrown = target;
|
thrown = target;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -205,7 +164,7 @@ public class stack018 extends Thread {
|
|||||||
//
|
//
|
||||||
// Optimization trick: allocate once, use everywhere.
|
// Optimization trick: allocate once, use everywhere.
|
||||||
//
|
//
|
||||||
method = stack018.class.getMethod("recurse");
|
method = Stack018.class.getMethod("recurse");
|
||||||
params = new Object[]{};
|
params = new Object[]{};
|
||||||
}
|
}
|
||||||
this.depth = depth; // actual parameter
|
this.depth = depth; // actual parameter
|
||||||
@ -215,10 +174,11 @@ public class stack018 extends Thread {
|
|||||||
private int depth = 0; // actual parameter for recurse()
|
private int depth = 0; // actual parameter for recurse()
|
||||||
|
|
||||||
public void recurse() throws Exception {
|
public void recurse() throws Exception {
|
||||||
if (depth > 0)
|
if (depth > 0) {
|
||||||
//
|
//
|
||||||
// Self-invoke via reflection:
|
// Self-invoke via reflection:
|
||||||
//
|
//
|
||||||
invokeRecurse(depth - 1);
|
invokeRecurse(depth - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -43,45 +43,22 @@
|
|||||||
*
|
*
|
||||||
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
|
||||||
* @requires os.family != "windows"
|
* @requires os.family != "windows"
|
||||||
* @library /vmTestbase
|
* @run main/othervm/timeout=900 -Xss200K Stack019
|
||||||
* @build nsk.share.Terminator
|
|
||||||
* @run main/othervm/timeout=900 -Xss200K nsk.stress.stack.stack019 -eager
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package nsk.stress.stack;
|
public class Stack019 {
|
||||||
|
|
||||||
|
|
||||||
import nsk.share.Terminator;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class stack019 {
|
|
||||||
private final static int CYCLES = 50;
|
private final static int CYCLES = 50;
|
||||||
private final static int PROBES = 50;
|
private final static int PROBES = 50;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
int exitCode = run(args, System.out);
|
|
||||||
System.exit(exitCode + 95);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int run(String args[], PrintStream out) {
|
|
||||||
boolean verbose = false, eager = false;
|
|
||||||
for (int i = 0; i < args.length; i++)
|
|
||||||
if (args[i].toLowerCase().equals("-verbose"))
|
|
||||||
verbose = true;
|
|
||||||
else if (args[i].toLowerCase().equals("-eager"))
|
|
||||||
eager = true;
|
|
||||||
if (!eager)
|
|
||||||
Terminator.appoint(Terminator.parseAppointment(args));
|
|
||||||
//
|
//
|
||||||
// Measure recursive depth before stack overflow:
|
// Measure recursive depth before stack overflow:
|
||||||
//
|
//
|
||||||
try {
|
try {
|
||||||
recurse(0);
|
recurse(0);
|
||||||
} catch (StackOverflowError soe) {
|
} catch (StackOverflowError | OutOfMemoryError err) {
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
}
|
}
|
||||||
out.println("Maximal recursion depth: " + maxDepth);
|
System.out.println("Maximal recursion depth: " + maxDepth);
|
||||||
depthToTry = maxDepth;
|
depthToTry = maxDepth;
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -89,23 +66,15 @@ public class stack019 {
|
|||||||
//
|
//
|
||||||
for (int i = 0; i < CYCLES; i++) {
|
for (int i = 0; i < CYCLES; i++) {
|
||||||
try {
|
try {
|
||||||
out.println("Iteration: " + i + "/" + CYCLES);
|
System.out.println("Iteration: " + i + "/" + CYCLES);
|
||||||
trickyRecurse(0);
|
trickyRecurse(0);
|
||||||
out.println("# TEST_BUG: stack overflow was expected!");
|
throw new RuntimeException("# TEST_BUG: stack overflow was expected!");
|
||||||
return 2;
|
} catch (StackOverflowError | OutOfMemoryError error) {
|
||||||
|
// It's OK
|
||||||
} catch (StackOverflowError error) {
|
|
||||||
} catch (OutOfMemoryError oome) {
|
|
||||||
// It's OK: stack overflow was expected.
|
|
||||||
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
if (throwable instanceof ThreadDeath)
|
throw new RuntimeException(throwable);
|
||||||
throw (ThreadDeath) throwable;
|
|
||||||
throwable.printStackTrace(out);
|
|
||||||
return 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int maxDepth;
|
private static int maxDepth;
|
||||||
@ -120,17 +89,14 @@ public class stack019 {
|
|||||||
try {
|
try {
|
||||||
maxDepth = depth;
|
maxDepth = depth;
|
||||||
trickyRecurse(depth + 1);
|
trickyRecurse(depth + 1);
|
||||||
} catch (Error error) {
|
} catch (StackOverflowError | OutOfMemoryError error){
|
||||||
if (!(error instanceof StackOverflowError) &&
|
|
||||||
!(error instanceof OutOfMemoryError))
|
|
||||||
throw error;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Stack problem caught: provoke it again,
|
// Stack problem caught: provoke it again,
|
||||||
// if current stack is enough deep:
|
// if current stack is enough deep:
|
||||||
//
|
//
|
||||||
if (depth < depthToTry - PROBES)
|
if (depth < depthToTry - PROBES) {
|
||||||
throw error;
|
throw error;
|
||||||
|
}
|
||||||
recurse(depth + 1);
|
recurse(depth + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ Short description of files:
|
|||||||
text processing:
|
text processing:
|
||||||
Grep.java, Paragrep.java
|
Grep.java, Paragrep.java
|
||||||
timeouts handling:
|
timeouts handling:
|
||||||
Terminator.java, TimeoutHandler.java
|
TimeoutHandler.java
|
||||||
tree structures support:
|
tree structures support:
|
||||||
Denotation.java, TreeNodesDenotation.java
|
Denotation.java, TreeNodesDenotation.java
|
||||||
RAS mode support:
|
RAS mode support:
|
||||||
|
@ -1,172 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
||||||
*
|
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
|
||||||
* under the terms of the GNU General Public License version 2 only, as
|
|
||||||
* published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
||||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* version 2 for more details (a copy is included in the LICENSE file that
|
|
||||||
* accompanied this code).
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License version
|
|
||||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
*
|
|
||||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
||||||
* or visit www.oracle.com if you need additional information or have any
|
|
||||||
* questions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package nsk.share;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Terminator is used to terminate a stress test with PASS exit status
|
|
||||||
* before the test is terminated as timed out (and so failed).
|
|
||||||
*
|
|
||||||
* <p>Terminator class holds a thread which sleeps for the given amount
|
|
||||||
* of time, and then wakes up and executes <tt>System.exit()</tt>
|
|
||||||
* with the given exit status. That thread is daemon, so it doesn't
|
|
||||||
* prevent application from exiting once all its threads finish
|
|
||||||
* before it's time for termination. Appointing terminator in zero
|
|
||||||
* delay implies immediate <tt>exit()</tt>.
|
|
||||||
*
|
|
||||||
* <p>There is a limitation: you may appoint no more than one terminator
|
|
||||||
* per application.
|
|
||||||
*/
|
|
||||||
public class Terminator {
|
|
||||||
/**
|
|
||||||
* Use specific <tt>appoint()</tt> method to appoint terminator.
|
|
||||||
*
|
|
||||||
* @see #appoint(int)
|
|
||||||
* @see #appoint(int,int)
|
|
||||||
*/
|
|
||||||
protected Terminator() {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* One terminator per application, or <tt>null</tt> (by default).
|
|
||||||
*/
|
|
||||||
private static Thread terminator = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Return timeout (or waittime) value munus the margin
|
|
||||||
* value (which is assumed 1 minute by default).
|
|
||||||
*
|
|
||||||
* <p>Treat <tt>args[0]</tt> as <tt>$TIMEOUT</tt> value, or seek for
|
|
||||||
* <tt>-waittime=$WAITTIME</tt> value. If both parameters
|
|
||||||
* (or either none of them) are assigned, throw an exception to
|
|
||||||
* report parameters inconsistency.
|
|
||||||
*
|
|
||||||
* <p>Also, seek for <tt>-margin=...</tt> assignment, or assume margin
|
|
||||||
* is 1 minute.
|
|
||||||
*
|
|
||||||
* @param args Is usually obtained via the application's command-line.
|
|
||||||
*
|
|
||||||
* @throws IllegalArgumentException If <tt>args[]</tt> is inconsistent.
|
|
||||||
*
|
|
||||||
* @see #appoint(int)
|
|
||||||
* @see #appoint(int,int)
|
|
||||||
*/
|
|
||||||
public static int parseAppointment(String args[]) {
|
|
||||||
int timeout=-1, margin=1;
|
|
||||||
int timeouts=0, waittimes=0, margins=0;
|
|
||||||
for (int i=0; i<args.length; i++) {
|
|
||||||
if (args[i].startsWith("-")) {
|
|
||||||
if (args[i].startsWith("-waittime=")) {
|
|
||||||
timeout = Integer.parseInt(args[i].substring(10));
|
|
||||||
waittimes++;
|
|
||||||
}
|
|
||||||
if (args[i].startsWith("-margin=")) {
|
|
||||||
margin = Integer.parseInt(args[i].substring(8));
|
|
||||||
margins++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (i == 0) {
|
|
||||||
timeout = Integer.parseInt(args[i]);
|
|
||||||
timeouts++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (timeouts==0 && waittimes==0)
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"no $TIMEOUT, nor -waittime=$WAITTIME is set");
|
|
||||||
if (waittimes > 1)
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"more than one -waittime=... is set");
|
|
||||||
if (margins > 1)
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"more than one -margin=... is set");
|
|
||||||
|
|
||||||
int result = timeout - margin;
|
|
||||||
if (result <= 0)
|
|
||||||
throw new IllegalArgumentException(
|
|
||||||
"delay appointment must be greater than "+margin+" minutes");
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appoint terminator after the given amount of <tt>minutes</tt>,
|
|
||||||
* so that exit status would be 95 (to simulate JCK-like PASS
|
|
||||||
* status).
|
|
||||||
*
|
|
||||||
* @throws IllegalStateException If terminator is already appointed.
|
|
||||||
*
|
|
||||||
* @see #appoint(int,int)
|
|
||||||
* @see #parseAppointment(String[])
|
|
||||||
*/
|
|
||||||
public static void appoint(int minutes) {
|
|
||||||
appoint(minutes,95); // JCK-like PASS status
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Appoint Terminator for the given amount of <tt>minutes</tt>,
|
|
||||||
* so that the given <tt>status</tt> would be exited when time
|
|
||||||
* is over.
|
|
||||||
*
|
|
||||||
* @throws IllegalStateException If terminator is already appointed.
|
|
||||||
*
|
|
||||||
* @see #appoint(int)
|
|
||||||
* @see #parseAppointment(String[])
|
|
||||||
*/
|
|
||||||
public static void appoint(int minutes, int status) {
|
|
||||||
if (terminator != null)
|
|
||||||
throw new IllegalStateException("Terminator is already appointed.");
|
|
||||||
|
|
||||||
final long timeToExit = System.currentTimeMillis() + 60*1000L*minutes;
|
|
||||||
final int exitStatus = status;
|
|
||||||
|
|
||||||
terminator = new Thread(Terminator.class.getName()) {
|
|
||||||
public void run() {
|
|
||||||
long timeToSleep = timeToExit - System.currentTimeMillis();
|
|
||||||
if (timeToSleep > 0)
|
|
||||||
try {
|
|
||||||
//
|
|
||||||
// Use wait() instead of sleep(), because Java 2
|
|
||||||
// specification doesn't guarantee the method
|
|
||||||
// sleep() to yield to other threads.
|
|
||||||
//
|
|
||||||
Object someDummyObject = new Object();
|
|
||||||
synchronized (someDummyObject) {
|
|
||||||
someDummyObject.wait(timeToSleep);
|
|
||||||
}
|
|
||||||
} catch (InterruptedException exception) {
|
|
||||||
exception.printStackTrace(System.err);
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
//
|
|
||||||
// OK, lets do it now:
|
|
||||||
//
|
|
||||||
System.err.println(
|
|
||||||
"#\n# Terminator: prescheduled program termination.\n#");
|
|
||||||
System.exit(exitStatus); // terminator to all threads
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
terminator.setPriority(Thread.MAX_PRIORITY);
|
|
||||||
terminator.setDaemon(true);
|
|
||||||
terminator.start();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user