author | erikj |
Tue, 12 Sep 2017 19:03:39 +0200 | |
changeset 47216 | 71c04702a3d5 |
parent 46351 | hotspot/test/runtime/Thread/TooSmallStackSize.java@1b8f8edb7775 |
child 54543 | 4fc566b7a9c0 |
permissions | -rw-r--r-- |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
1 |
/* |
46346
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
2 |
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
4 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
8 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
13 |
* accompanied this code). |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
14 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
18 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
21 |
* questions. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
22 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
23 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
24 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
25 |
* @test |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
26 |
* @bug 8140520 |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
27 |
* @summary Setting small CompilerThreadStackSize, ThreadStackSize, and |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
28 |
* VMThreadStackSize values should result in an error message that shows |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
29 |
* the minimum stack size value for each thread type. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
30 |
* @library /test/lib |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
31 |
* @modules java.base/jdk.internal.misc |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
32 |
* java.management |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
33 |
* @run main TooSmallStackSize |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
34 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
35 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
36 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
37 |
* The primary purpose of this test is to make sure we can run with a |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
38 |
* stack smaller than the minimum without crashing. Also this test will |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
39 |
* determine the minimum allowed stack size for the platform (as |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
40 |
* provided by the JVM error message when a very small stack is used), |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
41 |
* and then verify that the JVM can be launched with that stack size |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
42 |
* without a crash or any error messages. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
43 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
44 |
* Note: The '-Xss<size>' and '-XX:ThreadStackSize=<k-bytes>' options |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
45 |
* both control Java thread stack size. This repo's version of the test |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
46 |
* exercises the '-XX:ThreadStackSize' VM option. The jdk repo's version |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
47 |
* of the test exercises the '-Xss' option. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
48 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
49 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
50 |
import jdk.test.lib.process.ProcessTools; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
51 |
import jdk.test.lib.process.OutputAnalyzer; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
52 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
53 |
public class TooSmallStackSize { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
54 |
/* for debugging. Normally false. */ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
55 |
static final boolean verbose = false; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
56 |
static final String CompilerThreadStackSizeString = "CompilerThreadStackSize"; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
57 |
static final String ThreadStackSizeString = "Java thread stack size"; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
58 |
static final String VMThreadStackSizeString = "VMThreadStackSize"; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
59 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
60 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
61 |
* Returns the minimum stack size this platform will allowed based on the |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
62 |
* contents of the error message the JVM outputs when too small of a |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
63 |
* stack size was used. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
64 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
65 |
* The testOutput argument must contain the result of having already run |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
66 |
* the JVM with too small of a stack size. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
67 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
68 |
static String getMinStackAllowed(String testOutput) { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
69 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
70 |
* The JVM output will contain in one of the lines: |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
71 |
* "The CompilerThreadStackSize specified is too small. Specify at least 100k" |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
72 |
* "The Java thread stack size specified is too small. Specify at least 100k" |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
73 |
* "The VMThreadStackSize specified is too small. Specify at least 100k" |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
74 |
* Although the actual size will vary. We need to extract this size |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
75 |
* string from the output and return it. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
76 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
77 |
String matchStr = "Specify at least "; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
78 |
int match_idx = testOutput.indexOf(matchStr); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
79 |
if (match_idx >= 0) { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
80 |
int size_start_idx = match_idx + matchStr.length(); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
81 |
int k_start_idx = testOutput.indexOf("k", size_start_idx); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
82 |
// don't include the 'k'; the caller will have to |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
83 |
// add it back as needed. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
84 |
return testOutput.substring(size_start_idx, k_start_idx); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
85 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
86 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
87 |
System.out.println("Expect='" + matchStr + "'"); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
88 |
System.out.println("Actual: " + testOutput); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
89 |
System.out.println("FAILED: Could not get the stack size from the output"); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
90 |
throw new RuntimeException("test fails"); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
91 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
92 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
93 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
94 |
* Run the JVM with the specified stack size. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
95 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
96 |
* Returns the minimum allowed stack size gleaned from the error message, |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
97 |
* if there is an error message. Otherwise returns the stack size passed in. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
98 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
99 |
static String checkStack(String stackOption, String optionMesg, String stackSize) throws Exception { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
100 |
String min_stack_allowed; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
101 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
102 |
System.out.println("*** Testing " + stackOption + stackSize); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
103 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
104 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
105 |
stackOption + stackSize, |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
106 |
// Uncomment the following to get log output |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
107 |
// that shows actual thread creation sizes. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
108 |
// "-Xlog:os+thread", |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
109 |
"-version"); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
110 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
111 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
112 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
113 |
if (verbose) { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
114 |
System.out.println("stdout: " + output.getStdout()); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
115 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
116 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
117 |
if (output.getExitValue() == 0) { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
118 |
// checkMinStackAllowed() is called with stackSize values |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
119 |
// that should be the minimum that works. This method, |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
120 |
// checkStack(), is called with stackSize values that |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
121 |
// should be too small and result in error messages. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
122 |
// However, some platforms fix up a stackSize value that is |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
123 |
// too small into something that works so we have to allow |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
124 |
// for checkStack() calls that work. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
125 |
System.out.println("PASSED: got exit_code == 0 with " + stackOption + stackSize); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
126 |
min_stack_allowed = stackSize; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
127 |
} else { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
128 |
String expect = "The " + optionMesg + " specified is too small"; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
129 |
if (verbose) { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
130 |
System.out.println("Expect='" + expect + "'"); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
131 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
132 |
output.shouldContain(expect); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
133 |
min_stack_allowed = getMinStackAllowed(output.getStdout()); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
134 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
135 |
System.out.println("PASSED: got expected error message with " + stackOption + stackSize); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
136 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
137 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
138 |
return min_stack_allowed; |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
139 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
140 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
141 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
142 |
* Run the JVM with the minimum allowed stack size. This should always succeed. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
143 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
144 |
static void checkMinStackAllowed(String stackOption, String optionMesg, String stackSize) throws Exception { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
145 |
System.out.println("*** Testing " + stackOption + stackSize); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
146 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
147 |
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder( |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
148 |
stackOption + stackSize, |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
149 |
// Uncomment the following to get log output |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
150 |
// that shows actual thread creation sizes. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
151 |
// "-Xlog:os+thread", |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
152 |
"-version"); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
153 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
154 |
OutputAnalyzer output = new OutputAnalyzer(pb.start()); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
155 |
output.shouldHaveExitValue(0); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
156 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
157 |
System.out.println("PASSED: VM launched with " + stackOption + stackSize); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
158 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
159 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
160 |
public static void main(String... args) throws Exception { |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
161 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
162 |
* The result of a 16k stack size should be a quick exit with a complaint |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
163 |
* that the stack size is too small. However, for some win32 builds, the |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
164 |
* stack is always at least 64k, and this also sometimes is the minimum |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
165 |
* allowed size, so we won't see an error in this case. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
166 |
* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
167 |
* This test case will also produce a crash on some platforms if the fix |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
168 |
* for 6762191 is not yet in place. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
169 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
170 |
checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "16"); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
171 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
172 |
/* |
46351
1b8f8edb7775
8177015: STACK_SIZE_MINIMUM of 32k is not always enough for Mac OS X
cjplummer
parents:
46346
diff
changeset
|
173 |
* Try with a 64k stack size, which is the size that the launcher will |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
174 |
* set to if you try setting to anything smaller. This should produce the same |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
175 |
* result as setting to 16k if the fix for 6762191 is in place. |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
176 |
*/ |
46351
1b8f8edb7775
8177015: STACK_SIZE_MINIMUM of 32k is not always enough for Mac OS X
cjplummer
parents:
46346
diff
changeset
|
177 |
String min_stack_allowed = checkStack("-XX:ThreadStackSize=", ThreadStackSizeString, "64"); |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
178 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
179 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
180 |
* Try again with a the minimum stack size that was given in the error message |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
181 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
182 |
checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, min_stack_allowed); |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
183 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
184 |
/* |
46346
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
185 |
* Now try with a stack size that is not page aligned. |
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
186 |
*/ |
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
187 |
checkMinStackAllowed("-XX:ThreadStackSize=", ThreadStackSizeString, "513"); |
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
188 |
|
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
189 |
/* |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
190 |
* Now redo the same tests with the compiler thread stack size: |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
191 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
192 |
checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "16"); |
46351
1b8f8edb7775
8177015: STACK_SIZE_MINIMUM of 32k is not always enough for Mac OS X
cjplummer
parents:
46346
diff
changeset
|
193 |
min_stack_allowed = checkStack("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "64"); |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
194 |
checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, min_stack_allowed); |
46346
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
195 |
checkMinStackAllowed("-XX:CompilerThreadStackSize=", CompilerThreadStackSizeString, "513"); |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
196 |
|
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
197 |
/* |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
198 |
* Now redo the same tests with the VM thread stack size: |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
199 |
*/ |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
200 |
checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "16"); |
46351
1b8f8edb7775
8177015: STACK_SIZE_MINIMUM of 32k is not always enough for Mac OS X
cjplummer
parents:
46346
diff
changeset
|
201 |
min_stack_allowed = checkStack("-XX:VMThreadStackSize=", VMThreadStackSizeString, "64"); |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
202 |
checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, min_stack_allowed); |
46346
4085295dcf51
8176768: hotspot ignores PTHREAD_STACK_MIN when creating new threads
cjplummer
parents:
41070
diff
changeset
|
203 |
checkMinStackAllowed("-XX:VMThreadStackSize=", VMThreadStackSizeString, "513"); |
41070
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
204 |
} |
496463b4e206
8140520: segfault on solaris-amd64 with "-XX:VMThreadStackSize=1" option
rdurbin
parents:
diff
changeset
|
205 |
} |