Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java
40942 views
1
/*
2
* Copyright (c) 2013, 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
/*
26
* @test
27
* @bug 8065896
28
* @summary Synchronous signals during error reporting may terminate or hang VM process
29
* @library /test/lib
30
* @requires vm.debug
31
* @requires os.family != "windows"
32
* @author Thomas Stuefe (SAP)
33
* @modules java.base/jdk.internal.misc
34
* java.management
35
* @run driver SecondaryErrorTest
36
*/
37
38
import java.io.BufferedReader;
39
import java.io.File;
40
import java.io.FileInputStream;
41
import java.io.InputStreamReader;
42
import java.util.regex.Pattern;
43
44
import jdk.test.lib.process.OutputAnalyzer;
45
import jdk.test.lib.process.ProcessTools;
46
47
public class SecondaryErrorTest {
48
49
50
public static void main(String[] args) throws Exception {
51
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
52
"-XX:+UnlockDiagnosticVMOptions",
53
"-Xmx100M",
54
"-XX:-CreateCoredumpOnCrash",
55
"-XX:ErrorHandlerTest=15",
56
"-XX:TestCrashInErrorHandler=14",
57
"-version");
58
59
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
60
61
// we should have crashed with a SIGFPE
62
output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
63
output_detail.shouldMatch("#.+SIGFPE.*");
64
65
// extract hs-err file
66
String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
67
if (hs_err_file == null) {
68
throw new RuntimeException("Did not find hs-err file in output.\n");
69
}
70
71
// scan hs-err file: File should contain the "[error occurred during error reporting..]"
72
// markers which show that the secondary error handling kicked in and handled the
73
// error successfully. As an added test, we check that the last line contains "END.",
74
// which is an end marker written in the last step and proves that hs-err file was
75
// completely written.
76
File f = new File(hs_err_file);
77
if (!f.exists()) {
78
throw new RuntimeException("hs-err file missing at "
79
+ f.getAbsolutePath() + ".\n");
80
}
81
82
System.out.println("Found hs_err file. Scanning...");
83
84
FileInputStream fis = new FileInputStream(f);
85
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
86
String line = null;
87
88
Pattern [] pattern = new Pattern[] {
89
Pattern.compile("Will crash now \\(TestCrashInErrorHandler=14\\)..."),
90
Pattern.compile("\\[error occurred during error reporting \\(test secondary crash 1\\).*\\]"),
91
Pattern.compile("Will crash now \\(TestCrashInErrorHandler=14\\)..."),
92
Pattern.compile("\\[error occurred during error reporting \\(test secondary crash 2\\).*\\]"),
93
};
94
int currentPattern = 0;
95
96
String lastLine = null;
97
while ((line = br.readLine()) != null) {
98
if (currentPattern < pattern.length) {
99
if (pattern[currentPattern].matcher(line).matches()) {
100
System.out.println("Found: " + line + ".");
101
currentPattern ++;
102
}
103
}
104
lastLine = line;
105
}
106
br.close();
107
108
if (currentPattern < pattern.length) {
109
throw new RuntimeException("hs-err file incomplete (first missing pattern: " + currentPattern + ")");
110
}
111
112
if (!lastLine.equals("END.")) {
113
throw new RuntimeException("hs-err file incomplete (missing END marker.)");
114
} else {
115
System.out.println("End marker found.");
116
}
117
118
System.out.println("OK.");
119
120
}
121
122
}
123
124
125
126