Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/runtime/ErrorHandling/BadNativeStackInErrorHandlingTest.java
40942 views
1
/*
2
* Copyright (c) 2018, 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
import java.io.BufferedReader;
25
import java.io.File;
26
import java.io.FileInputStream;
27
import java.io.InputStreamReader;
28
import java.util.regex.Pattern;
29
30
import jdk.test.lib.process.OutputAnalyzer;
31
import jdk.test.lib.process.ProcessTools;
32
33
/*
34
* @test
35
* @bug 8194652
36
* @summary Printing native stack shows an "error occurred during error reporting".
37
* @modules java.base/jdk.internal.misc
38
* @requires vm.debug
39
* @requires vm.flavor != "zero"
40
* @library /test/lib
41
* @run driver BadNativeStackInErrorHandlingTest
42
*/
43
44
// This test was adapted from SafeFetchInErrorHandlingTest.java.
45
public class BadNativeStackInErrorHandlingTest {
46
public static void main(String[] args) throws Exception {
47
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
48
"-XX:+UnlockDiagnosticVMOptions",
49
"-Xmx100M",
50
"-XX:ErrorHandlerTest=14",
51
"-XX:-CreateCoredumpOnCrash",
52
"-version");
53
54
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
55
56
// we should have crashed with a SIGSEGV
57
output_detail.shouldMatch("# A fatal error has been detected by the Java Runtime Environment:.*");
58
output_detail.shouldMatch("# +(?:SIGSEGV|SIGBUS|EXCEPTION_ACCESS_VIOLATION).*");
59
60
// extract hs-err file
61
String hs_err_file = output_detail.firstMatch("# *(\\S*hs_err_pid\\d+\\.log)", 1);
62
if (hs_err_file == null) {
63
throw new RuntimeException("Did not find hs-err file in output.\n");
64
}
65
66
File f = new File(hs_err_file);
67
if (!f.exists()) {
68
throw new RuntimeException("hs-err file missing at " +
69
f.getAbsolutePath() + ".\n");
70
}
71
72
System.out.println("Found hs_err file. Scanning...");
73
74
FileInputStream fis = new FileInputStream(f);
75
BufferedReader br = new BufferedReader(new InputStreamReader(fis));
76
String line = null;
77
78
// The failing line looks like this:
79
// [error occurred during error reporting (printing native stack), id 0xb]
80
Pattern pattern =
81
Pattern.compile("\\[error occurred during error reporting \\(printing native stack\\), id .*\\]");
82
83
String lastLine = null;
84
while ((line = br.readLine()) != null) {
85
if (pattern.matcher(line).matches()) {
86
System.out.println("Found: " + line + ".");
87
throw new RuntimeException("hs-err file should not contain: '" +
88
pattern + "'");
89
}
90
lastLine = line;
91
}
92
br.close();
93
94
if (!lastLine.equals("END.")) {
95
throw new RuntimeException("hs-err file incomplete (missing END marker.)");
96
} else {
97
System.out.println("End marker found.");
98
}
99
100
System.out.println("OK.");
101
}
102
}
103
104