annotate test/runtime/ErrorHandling/TestCrashOnOutOfMemoryError.java @ 24231:18ae50e05080 jvmci-0.35

HotSpotResolvedJavaMethod.setNotInlineable() should be renamed to represent actual behavior (JDK-8180487)
author Doug Simon <doug.simon@oracle.com>
date Thu, 14 Sep 2017 13:00:31 +0200
parents 8641949eb21f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23487
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
1 /*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
4 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
7 * published by the Free Software Foundation.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
8 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
13 * accompanied this code).
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
14 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
18 *
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
21 * questions.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
22 */
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
23
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
24 /*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
25 * @test TestCrashOnOutOfMemoryError
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
26 * @summary Test using -XX:+CrashOnOutOfMemoryError
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
27 * @library /testlibrary
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
28 * @build jdk.test.lib.*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
29 * @run driver TestCrashOnOutOfMemoryError
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
30 * @bug 8138745
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
31 */
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
32
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
33 import com.oracle.java.testlibrary.OutputAnalyzer;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
34 import com.oracle.java.testlibrary.ProcessTools;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
35 import java.io.BufferedReader;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
36 import java.io.File;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
37 import java.io.FileInputStream;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
38 import java.io.InputStreamReader;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
39 import java.io.IOException;
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
40
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
41 public class TestCrashOnOutOfMemoryError {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
42
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
43 public static void main(String[] args) throws Exception {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
44 if (args.length == 1) {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
45 // This should guarantee to throw:
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
46 // java.lang.OutOfMemoryError: Requested array size exceeds VM limit
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
47 try {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
48 Object[] oa = new Object[Integer.MAX_VALUE];
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
49 throw new Error("OOME not triggered");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
50 } catch (OutOfMemoryError err) {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
51 throw new Error("OOME didn't abort JVM!");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
52 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
53 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
54 // else this is the main test
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
55 ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+CrashOnOutOfMemoryError",
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
56 "-Xmx64m", TestCrashOnOutOfMemoryError.class.getName(),"throwOOME");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
57 OutputAnalyzer output = new OutputAnalyzer(pb.start());
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
58 int exitValue = output.getExitValue();
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
59 if (0 == exitValue) {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
60 //expecting a non zero value
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
61 throw new Error("Expected to get non zero exit value");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
62 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
63
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
64 /* Output should look something like this. The actual text will depend on the OS and its core dump processing.
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
65 Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
66 # To suppress the following error report, specify this argument
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
67 # after -XX: or in .hotspotrc: SuppressErrorAt=/debug.cpp:303
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
68 #
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
69 # A fatal error has been detected by the Java Runtime Environment:
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
70 #
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
71 # Internal Error (/home/cheleswer/Desktop/jdk9/dev/hotspot/src/share/vm/utilities/debug.cpp:303), pid=6212, tid=6213
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
72 # fatal error: OutOfMemory encountered: Requested array size exceeds VM limit
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
73 #
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
74 # JRE version: OpenJDK Runtime Environment (9.0) (build 1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00)
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
75 # Java VM: OpenJDK 64-Bit Server VM (1.9.0-internal-debug-cheleswer_2015_10_20_14_32-b00, mixed mode, tiered, compressed oops, serial gc, linux-amd64)
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
76 # Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %P" (or dumping to
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
77 /home/cheleswer/Desktop/core.6212)
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
78 #
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
79 # An error report file with more information is saved as:
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
80 # /home/cheleswer/Desktop/hs_err_pid6212.log
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
81 #
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
82 # If you would like to submit a bug report, please visit:
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
83 # http://bugreport.java.com/bugreport/crash.jsp
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
84 #
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
85 Current thread is 6213
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
86 Dumping core ...
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
87 Aborted (core dumped)
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
88 */
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
89 output.shouldContain("Aborting due to java.lang.OutOfMemoryError: Requested array size exceeds VM limit");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
90 // extract hs-err file
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
91 String hs_err_file = output.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
92 if (hs_err_file == null) {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
93 throw new Error("Did not find hs-err file in output.\n");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
94 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
95
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
96 /*
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
97 * Check if hs_err files exist or not
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
98 */
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
99 File f = new File(hs_err_file);
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
100 if (!f.exists()) {
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
101 throw new Error("hs-err file missing at "+ f.getAbsolutePath() + ".\n");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
102 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
103
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
104 System.out.println("PASSED");
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
105 }
8641949eb21f 8138745: Implement ExitOnOutOfMemory and CrashOnOutOfMemory in HotSpot
kevinw
parents:
diff changeset
106 }