Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/vmTestbase/nsk/stress/stack/stack019.java
41159 views
1
/*
2
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @key stress
27
*
28
* @summary converted from VM testbase nsk/stress/stack/stack019.
29
* VM testbase keywords: [stress, diehard, stack, nonconcurrent]
30
* VM testbase readme:
31
* DESCRIPTION
32
* The test invokes infinitely recursive method from within stack
33
* overflow handler -- repeatedly multiple times in a single thread.
34
* The test is deemed passed, if VM have not crashed, and if exception
35
* other than due to stack overflow was not thrown.
36
* COMMENTS
37
* This test crashes HS versions 2.0, 1.3, and 1.4 on both
38
* Solaris and Win32 platforms.
39
* See the bug:
40
* 4366625 (P4/S4) multiple stack overflow causes HS crash
41
* The stack size is too small to run on systems with > 4K page size.
42
* Making it bigger could cause timeouts on other platform.
43
*
44
* @requires (vm.opt.DeoptimizeALot != true & vm.compMode != "Xcomp" & vm.pageSize == 4096)
45
* @requires os.family != "windows"
46
* @library /vmTestbase
47
* @build nsk.share.Terminator
48
* @run main/othervm/timeout=900 -Xss200K nsk.stress.stack.stack019 -eager
49
*/
50
51
package nsk.stress.stack;
52
53
54
import nsk.share.Terminator;
55
56
import java.io.PrintStream;
57
58
public class stack019 {
59
private final static int CYCLES = 50;
60
private final static int PROBES = 50;
61
62
public static void main(String[] args) {
63
int exitCode = run(args, System.out);
64
System.exit(exitCode + 95);
65
}
66
67
public static int run(String args[], PrintStream out) {
68
boolean verbose = false, eager = false;
69
for (int i = 0; i < args.length; i++)
70
if (args[i].toLowerCase().equals("-verbose"))
71
verbose = true;
72
else if (args[i].toLowerCase().equals("-eager"))
73
eager = true;
74
if (!eager)
75
Terminator.appoint(Terminator.parseAppointment(args));
76
//
77
// Measure recursive depth before stack overflow:
78
//
79
try {
80
recurse(0);
81
} catch (StackOverflowError soe) {
82
} catch (OutOfMemoryError oome) {
83
}
84
out.println("Maximal recursion depth: " + maxDepth);
85
depthToTry = maxDepth;
86
87
//
88
// Run the tested threads:
89
//
90
for (int i = 0; i < CYCLES; i++) {
91
try {
92
out.println("Iteration: " + i + "/" + CYCLES);
93
trickyRecurse(0);
94
out.println("# TEST_BUG: stack overflow was expected!");
95
return 2;
96
97
} catch (StackOverflowError error) {
98
} catch (OutOfMemoryError oome) {
99
// It's OK: stack overflow was expected.
100
101
} catch (Throwable throwable) {
102
if (throwable instanceof ThreadDeath)
103
throw (ThreadDeath) throwable;
104
throwable.printStackTrace(out);
105
return 2;
106
}
107
}
108
return 0;
109
}
110
111
private static int maxDepth;
112
private static int depthToTry;
113
114
private static void recurse(int depth) {
115
maxDepth = depth;
116
recurse(depth + 1);
117
}
118
119
private static void trickyRecurse(int depth) {
120
try {
121
maxDepth = depth;
122
trickyRecurse(depth + 1);
123
} catch (Error error) {
124
if (!(error instanceof StackOverflowError) &&
125
!(error instanceof OutOfMemoryError))
126
throw error;
127
128
//
129
// Stack problem caught: provoke it again,
130
// if current stack is enough deep:
131
//
132
if (depth < depthToTry - PROBES)
133
throw error;
134
recurse(depth + 1);
135
}
136
}
137
}
138
139