author | coleenp |
Tue, 09 Jun 2015 10:26:25 -0400 | |
changeset 31335 | 60081f497e75 |
parent 30773 | 3f15e2dc056b |
child 31356 | 55ee785c49c5 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
30125 | 2 |
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5403
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
28513
9464a1b5c184
8050807: Better performing performance data handling
gthornbr
parents:
27471
diff
changeset
|
25 |
#include <fcntl.h> |
7397 | 26 |
#include "precompiled.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
25351
diff
changeset
|
27 |
#include "code/codeCache.hpp" |
7397 | 28 |
#include "compiler/compileBroker.hpp" |
30764 | 29 |
#include "gc/shared/collectedHeap.hpp" |
12095 | 30 |
#include "prims/whitebox.hpp" |
7397 | 31 |
#include "runtime/arguments.hpp" |
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
32 |
#include "runtime/atomic.inline.hpp" |
7397 | 33 |
#include "runtime/frame.inline.hpp" |
34 |
#include "runtime/init.hpp" |
|
35 |
#include "runtime/os.hpp" |
|
24351
61b33cc6d3cf
8042195: Introduce umbrella header orderAccess.inline.hpp.
goetz
parents:
23204
diff
changeset
|
36 |
#include "runtime/thread.inline.hpp" |
7397 | 37 |
#include "runtime/vmThread.hpp" |
38 |
#include "runtime/vm_operations.hpp" |
|
13195 | 39 |
#include "services/memTracker.hpp" |
7397 | 40 |
#include "utilities/debug.hpp" |
7447
32c42d627f41
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
7397
diff
changeset
|
41 |
#include "utilities/decoder.hpp" |
7397 | 42 |
#include "utilities/defaultStream.hpp" |
8114
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
43 |
#include "utilities/errorReporter.hpp" |
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
44 |
#include "utilities/events.hpp" |
7397 | 45 |
#include "utilities/top.hpp" |
46 |
#include "utilities/vmError.hpp" |
|
1 | 47 |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
48 |
PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
49 |
|
1 | 50 |
// List of environment variables that should be reported in error log file. |
51 |
const char *env_list[] = { |
|
52 |
// All platforms |
|
53 |
"JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH", |
|
54 |
"JAVA_COMPILER", "PATH", "USERNAME", |
|
55 |
||
10565 | 56 |
// Env variables that are defined on Solaris/Linux/BSD |
1 | 57 |
"LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY", |
58 |
"HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE", |
|
59 |
||
60 |
// defined on Linux |
|
61 |
"LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM", |
|
62 |
||
10565 | 63 |
// defined on Darwin |
64 |
"DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH", |
|
65 |
"DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH", |
|
66 |
"DYLD_INSERT_LIBRARIES", |
|
67 |
||
1 | 68 |
// defined on Windows |
69 |
"OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR", |
|
70 |
||
71 |
(const char *)0 |
|
72 |
}; |
|
73 |
||
74 |
// Fatal error handler for internal errors and crashes. |
|
75 |
// |
|
76 |
// The default behavior of fatal error handler is to print a brief message |
|
77 |
// to standard out (defaultStream::output_fd()), then save detailed information |
|
78 |
// into an error report file (hs_err_pid<pid>.log) and abort VM. If multiple |
|
79 |
// threads are having troubles at the same time, only one error is reported. |
|
80 |
// The thread that is reporting error will abort VM when it is done, all other |
|
81 |
// threads are blocked forever inside report_and_die(). |
|
82 |
||
83 |
// Constructor for crashes |
|
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
84 |
VMError::VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context) { |
1 | 85 |
_thread = thread; |
86 |
_id = sig; |
|
87 |
_pc = pc; |
|
88 |
_siginfo = siginfo; |
|
89 |
_context = context; |
|
90 |
||
91 |
_verbose = false; |
|
92 |
_current_step = 0; |
|
93 |
_current_step_info = NULL; |
|
94 |
||
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
95 |
_message = NULL; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
96 |
_detail_msg = NULL; |
1 | 97 |
_filename = NULL; |
98 |
_lineno = 0; |
|
99 |
||
100 |
_size = 0; |
|
101 |
} |
|
102 |
||
103 |
// Constructor for internal errors |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
104 |
VMError::VMError(Thread* thread, const char* filename, int lineno, |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
105 |
const char* message, const char * detail_msg) |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
106 |
{ |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
107 |
_thread = thread; |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
108 |
_id = INTERNAL_ERROR; // Value that's not an OS exception/signal |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
109 |
_filename = filename; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
110 |
_lineno = lineno; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
111 |
_message = message; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
112 |
_detail_msg = detail_msg; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
113 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
114 |
_verbose = false; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
115 |
_current_step = 0; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
116 |
_current_step_info = NULL; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
117 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
118 |
_pc = NULL; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
119 |
_siginfo = NULL; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
120 |
_context = NULL; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
121 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
122 |
_size = 0; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
123 |
} |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
124 |
|
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
125 |
// Constructor for OOM errors |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
126 |
VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size, |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
127 |
VMErrorType vm_err_type, const char* message) { |
1 | 128 |
_thread = thread; |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
129 |
_id = vm_err_type; // Value that's not an OS exception/signal |
1 | 130 |
_filename = filename; |
131 |
_lineno = lineno; |
|
132 |
_message = message; |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
133 |
_detail_msg = NULL; |
1 | 134 |
|
135 |
_verbose = false; |
|
136 |
_current_step = 0; |
|
137 |
_current_step_info = NULL; |
|
138 |
||
139 |
_pc = NULL; |
|
140 |
_siginfo = NULL; |
|
141 |
_context = NULL; |
|
142 |
||
143 |
_size = size; |
|
144 |
} |
|
145 |
||
146 |
||
147 |
// Constructor for non-fatal errors |
|
148 |
VMError::VMError(const char* message) { |
|
149 |
_thread = NULL; |
|
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
150 |
_id = INTERNAL_ERROR; // Value that's not an OS exception/signal |
1 | 151 |
_filename = NULL; |
152 |
_lineno = 0; |
|
153 |
_message = message; |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
154 |
_detail_msg = NULL; |
1 | 155 |
|
156 |
_verbose = false; |
|
157 |
_current_step = 0; |
|
158 |
_current_step_info = NULL; |
|
159 |
||
160 |
_pc = NULL; |
|
161 |
_siginfo = NULL; |
|
162 |
_context = NULL; |
|
163 |
||
164 |
_size = 0; |
|
165 |
} |
|
166 |
||
167 |
// -XX:OnError=<string>, where <string> can be a list of commands, separated |
|
168 |
// by ';'. "%p" is replaced by current process id (pid); "%%" is replaced by |
|
169 |
// a single "%". Some examples: |
|
170 |
// |
|
171 |
// -XX:OnError="pmap %p" // show memory map |
|
172 |
// -XX:OnError="gcore %p; dbx - %p" // dump core and launch debugger |
|
173 |
// -XX:OnError="cat hs_err_pid%p.log | mail my_email@sun.com" |
|
174 |
// -XX:OnError="kill -9 %p" // ?#!@# |
|
175 |
||
176 |
// A simple parser for -XX:OnError, usage: |
|
177 |
// ptr = OnError; |
|
178 |
// while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr) != NULL) |
|
179 |
// ... ... |
|
180 |
static char* next_OnError_command(char* buf, int buflen, const char** ptr) { |
|
181 |
if (ptr == NULL || *ptr == NULL) return NULL; |
|
182 |
||
183 |
const char* cmd = *ptr; |
|
184 |
||
185 |
// skip leading blanks or ';' |
|
186 |
while (*cmd == ' ' || *cmd == ';') cmd++; |
|
187 |
||
188 |
if (*cmd == '\0') return NULL; |
|
189 |
||
190 |
const char * cmdend = cmd; |
|
191 |
while (*cmdend != '\0' && *cmdend != ';') cmdend++; |
|
192 |
||
193 |
Arguments::copy_expand_pid(cmd, cmdend - cmd, buf, buflen); |
|
194 |
||
195 |
*ptr = (*cmdend == '\0' ? cmdend : cmdend + 1); |
|
196 |
return buf; |
|
197 |
} |
|
198 |
||
199 |
||
200 |
static void print_bug_submit_message(outputStream *out, Thread *thread) { |
|
201 |
if (out == NULL) return; |
|
202 |
out->print_raw_cr("# If you would like to submit a bug report, please visit:"); |
|
203 |
out->print_raw ("# "); |
|
204 |
out->print_raw_cr(Arguments::java_vendor_url_bug()); |
|
205 |
// If the crash is in native code, encourage user to submit a bug to the |
|
206 |
// provider of that code. |
|
229
4fddba548751
6549844: Wording problems in "An unexpected error ..."
coleenp
parents:
1
diff
changeset
|
207 |
if (thread && thread->is_Java_thread() && |
4fddba548751
6549844: Wording problems in "An unexpected error ..."
coleenp
parents:
1
diff
changeset
|
208 |
!thread->is_hidden_from_external_view()) { |
1 | 209 |
JavaThread* jt = (JavaThread*)thread; |
210 |
if (jt->thread_state() == _thread_in_native) { |
|
211 |
out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug."); |
|
212 |
} |
|
213 |
} |
|
214 |
out->print_raw_cr("#"); |
|
215 |
} |
|
216 |
||
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
217 |
bool VMError::coredump_status; |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
218 |
char VMError::coredump_message[O_BUFLEN]; |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
219 |
|
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
220 |
void VMError::record_coredump_status(const char* message, bool status) { |
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
221 |
coredump_status = status; |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
222 |
strncpy(coredump_message, message, sizeof(coredump_message)); |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
223 |
coredump_message[sizeof(coredump_message)-1] = 0; |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
224 |
} |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
225 |
|
1 | 226 |
|
227 |
// Return a string to describe the error |
|
228 |
char* VMError::error_string(char* buf, int buflen) { |
|
229 |
char signame_buf[64]; |
|
230 |
const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf)); |
|
231 |
||
232 |
if (signame) { |
|
233 |
jio_snprintf(buf, buflen, |
|
30241
4cf8974e0d20
8029630: Thread id should be displayed as a hex number in error report
mockner
parents:
30240
diff
changeset
|
234 |
"%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" INTPTR_FORMAT, |
1 | 235 |
signame, _id, _pc, |
236 |
os::current_process_id(), os::current_thread_id()); |
|
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
237 |
} else if (_filename != NULL && _lineno > 0) { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
238 |
// skip directory names |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
239 |
char separator = os::file_separator()[0]; |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
240 |
const char *p = strrchr(_filename, separator); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
241 |
int n = jio_snprintf(buf, buflen, |
30241
4cf8974e0d20
8029630: Thread id should be displayed as a hex number in error report
mockner
parents:
30240
diff
changeset
|
242 |
"Internal Error at %s:%d, pid=%d, tid=" INTPTR_FORMAT, |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
243 |
p ? p + 1 : _filename, _lineno, |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
244 |
os::current_process_id(), os::current_thread_id()); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
245 |
if (n >= 0 && n < buflen && _message) { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
246 |
if (_detail_msg) { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
247 |
jio_snprintf(buf + n, buflen - n, "%s%s: %s", |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
248 |
os::line_separator(), _message, _detail_msg); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
249 |
} else { |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
250 |
jio_snprintf(buf + n, buflen - n, "%sError: %s", |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
251 |
os::line_separator(), _message); |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
252 |
} |
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
253 |
} |
1 | 254 |
} else { |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
255 |
jio_snprintf(buf, buflen, |
30241
4cf8974e0d20
8029630: Thread id should be displayed as a hex number in error report
mockner
parents:
30240
diff
changeset
|
256 |
"Internal Error (0x%x), pid=%d, tid=" INTPTR_FORMAT, |
5403
6b0dd9c75dde
6888954: argument formatting for assert() and friends
jcoomes
parents:
5340
diff
changeset
|
257 |
_id, os::current_process_id(), os::current_thread_id()); |
1 | 258 |
} |
259 |
||
260 |
return buf; |
|
261 |
} |
|
262 |
||
5340 | 263 |
void VMError::print_stack_trace(outputStream* st, JavaThread* jt, |
264 |
char* buf, int buflen, bool verbose) { |
|
265 |
#ifdef ZERO |
|
266 |
if (jt->zero_stack()->sp() && jt->top_zero_frame()) { |
|
267 |
// StackFrameStream uses the frame anchor, which may not have |
|
268 |
// been set up. This can be done at any time in Zero, however, |
|
269 |
// so if it hasn't been set up then we just set it up now and |
|
270 |
// clear it again when we're done. |
|
271 |
bool has_last_Java_frame = jt->has_last_Java_frame(); |
|
272 |
if (!has_last_Java_frame) |
|
273 |
jt->set_last_Java_frame(); |
|
274 |
st->print("Java frames:"); |
|
275 |
||
276 |
// If the top frame is a Shark frame and the frame anchor isn't |
|
277 |
// set up then it's possible that the information in the frame |
|
278 |
// is garbage: it could be from a previous decache, or it could |
|
279 |
// simply have never been written. So we print a warning... |
|
280 |
StackFrameStream sfs(jt); |
|
281 |
if (!has_last_Java_frame && !sfs.is_done()) { |
|
282 |
if (sfs.current()->zeroframe()->is_shark_frame()) { |
|
283 |
st->print(" (TOP FRAME MAY BE JUNK)"); |
|
284 |
} |
|
285 |
} |
|
286 |
st->cr(); |
|
287 |
||
288 |
// Print the frames |
|
289 |
for(int i = 0; !sfs.is_done(); sfs.next(), i++) { |
|
290 |
sfs.current()->zero_print_on_error(i, st, buf, buflen); |
|
291 |
st->cr(); |
|
292 |
} |
|
293 |
||
294 |
// Reset the frame anchor if necessary |
|
295 |
if (!has_last_Java_frame) |
|
296 |
jt->reset_last_Java_frame(); |
|
297 |
} |
|
298 |
#else |
|
299 |
if (jt->has_last_Java_frame()) { |
|
300 |
st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); |
|
301 |
for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { |
|
302 |
sfs.current()->print_on_error(st, buf, buflen, verbose); |
|
303 |
st->cr(); |
|
304 |
} |
|
305 |
} |
|
306 |
#endif // ZERO |
|
307 |
} |
|
1 | 308 |
|
309 |
// This is the main function to report a fatal error. Only one thread can |
|
310 |
// call this function, so we don't need to worry about MT-safety. But it's |
|
311 |
// possible that the error handler itself may crash or die on an internal |
|
312 |
// error, for example, when the stack/heap is badly damaged. We must be |
|
313 |
// able to handle recursive errors that happen inside error handler. |
|
314 |
// |
|
315 |
// Error reporting is done in several steps. If a crash or internal error |
|
316 |
// occurred when reporting an error, the nested signal/exception handler |
|
317 |
// can skip steps that are already (or partially) done. Error reporting will |
|
318 |
// continue from the next step. This allows us to retrieve and print |
|
319 |
// information that may be unsafe to get after a fatal error. If it happens, |
|
320 |
// you may find nested report_and_die() frames when you look at the stack |
|
321 |
// in a debugger. |
|
322 |
// |
|
323 |
// In general, a hang in error handler is much worse than a crash or internal |
|
324 |
// error, as it's harder to recover from a hang. Deadlock can happen if we |
|
325 |
// try to grab a lock that is already owned by current thread, or if the |
|
326 |
// owner is blocked forever (e.g. in os::infinite_sleep()). If possible, the |
|
327 |
// error handler and all the functions it called should avoid grabbing any |
|
328 |
// lock. An important thing to notice is that memory allocation needs a lock. |
|
329 |
// |
|
330 |
// We should avoid using large stack allocated buffers. Many errors happen |
|
331 |
// when stack space is already low. Making things even worse is that there |
|
332 |
// could be nested report_and_die() calls on stack (see above). Only one |
|
333 |
// thread can report error, so large buffers are statically allocated in data |
|
334 |
// segment. |
|
335 |
||
336 |
void VMError::report(outputStream* st) { |
|
337 |
# define BEGIN if (_current_step == 0) { _current_step = 1; |
|
338 |
# define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s; |
|
339 |
# define END } |
|
340 |
||
341 |
// don't allocate large buffer on stack |
|
342 |
static char buf[O_BUFLEN]; |
|
343 |
||
344 |
BEGIN |
|
345 |
||
229
4fddba548751
6549844: Wording problems in "An unexpected error ..."
coleenp
parents:
1
diff
changeset
|
346 |
STEP(10, "(printing fatal error message)") |
1 | 347 |
|
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
348 |
st->print_cr("#"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
349 |
if (should_report_bug(_id)) { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
350 |
st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
351 |
} else { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
352 |
st->print_cr("# There is insufficient memory for the Java " |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
353 |
"Runtime Environment to continue."); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
354 |
} |
1 | 355 |
|
28943
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
356 |
#ifndef PRODUCT |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
357 |
// Error handler self tests |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
358 |
|
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
359 |
// test secondary error handling. Test it twice, to test that resetting |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
360 |
// error handler after a secondary crash works. |
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
361 |
STEP(11, "(test secondary crash 1)") |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
362 |
if (_verbose && TestCrashInErrorHandler != 0) { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
363 |
st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...", |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
364 |
TestCrashInErrorHandler); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
365 |
controlled_crash(TestCrashInErrorHandler); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
366 |
} |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
367 |
|
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
368 |
STEP(12, "(test secondary crash 2)") |
28943
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
369 |
if (_verbose && TestCrashInErrorHandler != 0) { |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
370 |
st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...", |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
371 |
TestCrashInErrorHandler); |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
372 |
controlled_crash(TestCrashInErrorHandler); |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
373 |
} |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
374 |
|
29573
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
375 |
STEP(13, "(test safefetch in error handler)") |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
376 |
// test whether it is safe to use SafeFetch32 in Crash Handler. Test twice |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
377 |
// to test that resetting the signal handler works correctly. |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
378 |
if (_verbose && TestSafeFetchInErrorHandler) { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
379 |
st->print_cr("Will test SafeFetch..."); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
380 |
if (CanUseSafeFetch32()) { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
381 |
int* const invalid_pointer = (int*) get_segfault_address(); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
382 |
const int x = 0x76543210; |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
383 |
int i1 = SafeFetch32(invalid_pointer, x); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
384 |
int i2 = SafeFetch32(invalid_pointer, x); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
385 |
if (i1 == x && i2 == x) { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
386 |
st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
387 |
} else { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
388 |
st->print_cr("??"); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
389 |
} |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
390 |
} else { |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
391 |
st->print_cr("not possible; skipped."); |
2d800e5d575f
8074552: SafeFetch32 and SafeFetchN do not work in error handling
dholmes
parents:
28943
diff
changeset
|
392 |
} |
28943
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
393 |
} |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
394 |
#endif // PRODUCT |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
395 |
|
1 | 396 |
STEP(15, "(printing type of error)") |
397 |
||
398 |
switch(_id) { |
|
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
399 |
case OOM_MALLOC_ERROR: |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
400 |
case OOM_MMAP_ERROR: |
1 | 401 |
if (_size) { |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
402 |
st->print("# Native memory allocation "); |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
403 |
st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " : |
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
404 |
"(mmap) failed to map "); |
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
405 |
jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
406 |
st->print("%s", buf); |
1 | 407 |
st->print(" bytes"); |
408 |
if (_message != NULL) { |
|
409 |
st->print(" for "); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
410 |
st->print("%s", _message); |
1 | 411 |
} |
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
412 |
st->cr(); |
1 | 413 |
} else { |
414 |
if (_message != NULL) |
|
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
415 |
st->print("# "); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
416 |
st->print_cr("%s", _message); |
1 | 417 |
} |
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
418 |
// In error file give some solutions |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
419 |
if (_verbose) { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
420 |
st->print_cr("# Possible reasons:"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
421 |
st->print_cr("# The system is out of physical RAM or swap space"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
422 |
st->print_cr("# In 32 bit mode, the process size limit was hit"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
423 |
st->print_cr("# Possible solutions:"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
424 |
st->print_cr("# Reduce memory load on the system"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
425 |
st->print_cr("# Increase physical memory or swap space"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
426 |
st->print_cr("# Check if swap backing store is full"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
427 |
st->print_cr("# Use 64 bit Java on a 64 bit OS"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
428 |
st->print_cr("# Decrease Java heap size (-Xmx/-Xms)"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
429 |
st->print_cr("# Decrease number of Java threads"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
430 |
st->print_cr("# Decrease Java thread stack sizes (-Xss)"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
431 |
st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize="); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
432 |
st->print_cr("# This output file may be truncated or incomplete."); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
433 |
} else { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
434 |
return; // that's enough for the screen |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
435 |
} |
1 | 436 |
break; |
17087
f0b76c4c93a0
8011661: Insufficient memory message says "malloc" when sometimes it should say "mmap"
ccheung
parents:
16685
diff
changeset
|
437 |
case INTERNAL_ERROR: |
1 | 438 |
default: |
439 |
break; |
|
440 |
} |
|
441 |
||
442 |
STEP(20, "(printing exception/signal name)") |
|
443 |
||
444 |
st->print_cr("#"); |
|
445 |
st->print("# "); |
|
446 |
// Is it an OS exception/signal? |
|
447 |
if (os::exception_name(_id, buf, sizeof(buf))) { |
|
448 |
st->print("%s", buf); |
|
449 |
st->print(" (0x%x)", _id); // signal number |
|
450 |
st->print(" at pc=" PTR_FORMAT, _pc); |
|
451 |
} else { |
|
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
452 |
if (should_report_bug(_id)) { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
453 |
st->print("Internal Error"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
454 |
} else { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
455 |
st->print("Out of Memory Error"); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
456 |
} |
1 | 457 |
if (_filename != NULL && _lineno > 0) { |
458 |
#ifdef PRODUCT |
|
459 |
// In product mode chop off pathname? |
|
460 |
char separator = os::file_separator()[0]; |
|
461 |
const char *p = strrchr(_filename, separator); |
|
462 |
const char *file = p ? p+1 : _filename; |
|
463 |
#else |
|
464 |
const char *file = _filename; |
|
465 |
#endif |
|
30281 | 466 |
st->print(" (%s:%d)", file, _lineno); |
1 | 467 |
} else { |
468 |
st->print(" (0x%x)", _id); |
|
469 |
} |
|
470 |
} |
|
471 |
||
472 |
STEP(30, "(printing current thread and pid)") |
|
473 |
||
474 |
// process id, thread id |
|
475 |
st->print(", pid=%d", os::current_process_id()); |
|
30241
4cf8974e0d20
8029630: Thread id should be displayed as a hex number in error report
mockner
parents:
30240
diff
changeset
|
476 |
st->print(", tid=" INTPTR_FORMAT, os::current_thread_id()); |
1 | 477 |
st->cr(); |
478 |
||
479 |
STEP(40, "(printing error message)") |
|
480 |
||
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
481 |
if (should_report_bug(_id)) { // already printed the message. |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
482 |
// error message |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
483 |
if (_detail_msg) { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
484 |
st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
485 |
} else if (_message) { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
486 |
st->print_cr("# Error: %s", _message); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
487 |
} |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
488 |
} |
1 | 489 |
|
490 |
STEP(50, "(printing Java version string)") |
|
491 |
||
492 |
// VM version |
|
493 |
st->print_cr("#"); |
|
1660
86be56b9ba46
6689685: Hotspot crash error message should include libraries version
coleenp
parents:
1500
diff
changeset
|
494 |
JDK_Version::current().to_string(buf, sizeof(buf)); |
13106 | 495 |
const char* runtime_name = JDK_Version::runtime_name() != NULL ? |
496 |
JDK_Version::runtime_name() : ""; |
|
14289
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13196
diff
changeset
|
497 |
const char* runtime_version = JDK_Version::runtime_version() != NULL ? |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13196
diff
changeset
|
498 |
JDK_Version::runtime_version() : ""; |
aec758622b4b
8002078: hs_err_pid file should report full JDK version string
sla
parents:
13196
diff
changeset
|
499 |
st->print_cr("# JRE version: %s (%s) (build %s)", runtime_name, buf, runtime_version); |
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
229
diff
changeset
|
500 |
st->print_cr("# Java VM: %s (%s %s %s %s)", |
1 | 501 |
Abstract_VM_Version::vm_name(), |
502 |
Abstract_VM_Version::vm_release(), |
|
503 |
Abstract_VM_Version::vm_info_string(), |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
229
diff
changeset
|
504 |
Abstract_VM_Version::vm_platform_string(), |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
229
diff
changeset
|
505 |
UseCompressedOops ? "compressed oops" : "" |
1 | 506 |
); |
507 |
||
508 |
STEP(60, "(printing problematic frame)") |
|
509 |
||
510 |
// Print current frame if we have a context (i.e. it's a crash) |
|
511 |
if (_context) { |
|
512 |
st->print_cr("# Problematic frame:"); |
|
513 |
st->print("# "); |
|
514 |
frame fr = os::fetch_frame_from_context(_context); |
|
515 |
fr.print_on_error(st, buf, sizeof(buf)); |
|
516 |
st->cr(); |
|
517 |
st->print_cr("#"); |
|
518 |
} |
|
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
519 |
STEP(63, "(printing core file information)") |
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
520 |
st->print("# "); |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
521 |
if (CreateCoredumpOnCrash) { |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
522 |
if (coredump_status) { |
30622
648d51c142bd
8078121: Add 'CreateMinidumpOnCrash' (JDK-8074354) caused many tests failed in nightly testing
ctornqvi
parents:
30281
diff
changeset
|
523 |
st->print("Core dump will be written. Default location: %s", coredump_message); |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
524 |
} else { |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
525 |
st->print("No core dump will be written. %s", coredump_message); |
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
526 |
} |
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
527 |
} else { |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
528 |
st->print("CreateCoredumpOnCrash turned off, no core file dumped"); |
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
529 |
} |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
24351
diff
changeset
|
530 |
st->cr(); |
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
531 |
st->print_cr("#"); |
1 | 532 |
|
533 |
STEP(65, "(printing bug submit message)") |
|
534 |
||
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
535 |
if (should_report_bug(_id) && _verbose) { |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
536 |
print_bug_submit_message(st, _thread); |
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
537 |
} |
1 | 538 |
|
539 |
STEP(70, "(printing thread)" ) |
|
540 |
||
541 |
if (_verbose) { |
|
542 |
st->cr(); |
|
543 |
st->print_cr("--------------- T H R E A D ---------------"); |
|
544 |
st->cr(); |
|
545 |
} |
|
546 |
||
547 |
STEP(80, "(printing current thread)" ) |
|
548 |
||
549 |
// current thread |
|
550 |
if (_verbose) { |
|
551 |
if (_thread) { |
|
552 |
st->print("Current thread (" PTR_FORMAT "): ", _thread); |
|
553 |
_thread->print_on_error(st, buf, sizeof(buf)); |
|
554 |
st->cr(); |
|
555 |
} else { |
|
556 |
st->print_cr("Current thread is native thread"); |
|
557 |
} |
|
558 |
st->cr(); |
|
559 |
} |
|
560 |
||
561 |
STEP(90, "(printing siginfo)" ) |
|
562 |
||
563 |
// signal no, signal code, address that caused the fault |
|
564 |
if (_verbose && _siginfo) { |
|
565 |
os::print_siginfo(st, _siginfo); |
|
566 |
st->cr(); |
|
567 |
} |
|
568 |
||
569 |
STEP(100, "(printing registers, top of stack, instructions near pc)") |
|
570 |
||
571 |
// registers, top of stack, instructions near pc |
|
572 |
if (_verbose && _context) { |
|
573 |
os::print_context(st, _context); |
|
574 |
st->cr(); |
|
575 |
} |
|
576 |
||
7108 | 577 |
STEP(105, "(printing register info)") |
578 |
||
579 |
// decode register contents if possible |
|
580 |
if (_verbose && _context && Universe::is_fully_initialized()) { |
|
581 |
os::print_register_info(st, _context); |
|
582 |
st->cr(); |
|
583 |
} |
|
584 |
||
1 | 585 |
STEP(110, "(printing stack bounds)" ) |
586 |
||
587 |
if (_verbose) { |
|
588 |
st->print("Stack: "); |
|
589 |
||
590 |
address stack_top; |
|
591 |
size_t stack_size; |
|
592 |
||
593 |
if (_thread) { |
|
594 |
stack_top = _thread->stack_base(); |
|
595 |
stack_size = _thread->stack_size(); |
|
596 |
} else { |
|
597 |
stack_top = os::current_stack_base(); |
|
598 |
stack_size = os::current_stack_size(); |
|
599 |
} |
|
600 |
||
601 |
address stack_bottom = stack_top - stack_size; |
|
602 |
st->print("[" PTR_FORMAT "," PTR_FORMAT "]", stack_bottom, stack_top); |
|
603 |
||
604 |
frame fr = _context ? os::fetch_frame_from_context(_context) |
|
605 |
: os::current_frame(); |
|
606 |
||
607 |
if (fr.sp()) { |
|
608 |
st->print(", sp=" PTR_FORMAT, fr.sp()); |
|
6179
4846648c4b7b
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
5547
diff
changeset
|
609 |
size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024); |
4846648c4b7b
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
5547
diff
changeset
|
610 |
st->print(", free space=" SIZE_FORMAT "k", free_stack_size); |
1 | 611 |
} |
612 |
||
613 |
st->cr(); |
|
614 |
} |
|
615 |
||
616 |
STEP(120, "(printing native stack)" ) |
|
617 |
||
26821
ce9f82507dc2
8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents:
25946
diff
changeset
|
618 |
if (_verbose) { |
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
19334
diff
changeset
|
619 |
if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) { |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
19334
diff
changeset
|
620 |
// We have printed the native stack in platform-specific code |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
19334
diff
changeset
|
621 |
// Windows/x64 needs special handling. |
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
19334
diff
changeset
|
622 |
} else { |
1 | 623 |
frame fr = _context ? os::fetch_frame_from_context(_context) |
624 |
: os::current_frame(); |
|
625 |
||
26821
ce9f82507dc2
8058345: Refactor native stack printing from vmError.cpp to debug.cpp to make it available in gdb as well
simonis
parents:
25946
diff
changeset
|
626 |
print_native_stack(st, fr, _thread, buf, sizeof(buf)); |
1 | 627 |
} |
19952
bc974e92f881
8022335: Native stack walk while generating hs_err does not work on Windows x64
iklam
parents:
19334
diff
changeset
|
628 |
} |
1 | 629 |
|
630 |
STEP(130, "(printing Java stack)" ) |
|
631 |
||
632 |
if (_verbose && _thread && _thread->is_Java_thread()) { |
|
5340 | 633 |
print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf)); |
1 | 634 |
} |
635 |
||
4489
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
636 |
STEP(135, "(printing target Java thread stack)" ) |
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
637 |
|
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
638 |
// printing Java thread stack trace if it is involved in GC crash |
7108 | 639 |
if (_verbose && _thread && (_thread->is_Named_thread())) { |
4489
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
640 |
JavaThread* jt = ((NamedThread *)_thread)->processed_thread(); |
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
641 |
if (jt != NULL) { |
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
642 |
st->print_cr("JavaThread " PTR_FORMAT " (nid = " UINTX_FORMAT ") was being processed", jt, jt->osthread()->thread_id()); |
5340 | 643 |
print_stack_trace(st, jt, buf, sizeof(buf), true); |
4489
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
644 |
} |
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
645 |
} |
514173c9a0c2
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
4013
diff
changeset
|
646 |
|
1 | 647 |
STEP(140, "(printing VM operation)" ) |
648 |
||
649 |
if (_verbose && _thread && _thread->is_VM_thread()) { |
|
650 |
VMThread* t = (VMThread*)_thread; |
|
651 |
VM_Operation* op = t->vm_operation(); |
|
652 |
if (op) { |
|
653 |
op->print_on_error(st); |
|
654 |
st->cr(); |
|
655 |
st->cr(); |
|
656 |
} |
|
657 |
} |
|
658 |
||
659 |
STEP(150, "(printing current compile task)" ) |
|
660 |
||
661 |
if (_verbose && _thread && _thread->is_Compiler_thread()) { |
|
662 |
CompilerThread* t = (CompilerThread*)_thread; |
|
663 |
if (t->task()) { |
|
664 |
st->cr(); |
|
665 |
st->print_cr("Current CompileTask:"); |
|
666 |
t->task()->print_line_on_error(st, buf, sizeof(buf)); |
|
667 |
st->cr(); |
|
668 |
} |
|
669 |
} |
|
670 |
||
671 |
STEP(160, "(printing process)" ) |
|
672 |
||
673 |
if (_verbose) { |
|
674 |
st->cr(); |
|
675 |
st->print_cr("--------------- P R O C E S S ---------------"); |
|
676 |
st->cr(); |
|
677 |
} |
|
678 |
||
679 |
STEP(170, "(printing all threads)" ) |
|
680 |
||
681 |
// all threads |
|
682 |
if (_verbose && _thread) { |
|
683 |
Threads::print_on_error(st, _thread, buf, sizeof(buf)); |
|
684 |
st->cr(); |
|
685 |
} |
|
686 |
||
687 |
STEP(175, "(printing VM state)" ) |
|
688 |
||
689 |
if (_verbose) { |
|
690 |
// Safepoint state |
|
691 |
st->print("VM state:"); |
|
692 |
||
693 |
if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing"); |
|
694 |
else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint"); |
|
695 |
else st->print("not at safepoint"); |
|
696 |
||
697 |
// Also see if error occurred during initialization or shutdown |
|
698 |
if (!Universe::is_fully_initialized()) { |
|
699 |
st->print(" (not fully initialized)"); |
|
700 |
} else if (VM_Exit::vm_exited()) { |
|
701 |
st->print(" (shutting down)"); |
|
702 |
} else { |
|
703 |
st->print(" (normal execution)"); |
|
704 |
} |
|
705 |
st->cr(); |
|
706 |
st->cr(); |
|
707 |
} |
|
708 |
||
709 |
STEP(180, "(printing owned locks on error)" ) |
|
710 |
||
711 |
// mutexes/monitors that currently have an owner |
|
712 |
if (_verbose) { |
|
713 |
print_owned_locks_on_error(st); |
|
714 |
st->cr(); |
|
715 |
} |
|
716 |
||
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
717 |
STEP(182, "(printing number of OutOfMemoryError and StackOverflow exceptions)") |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
718 |
|
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
719 |
if (_verbose && Exceptions::has_exception_counts()) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
720 |
st->print_cr("OutOfMemory and StackOverflow Exception counts:"); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
721 |
Exceptions::print_exception_counts_on_error(st); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
722 |
st->cr(); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
723 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
724 |
|
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
725 |
STEP(185, "(printing compressed oops mode") |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
726 |
|
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
727 |
if (_verbose && UseCompressedOops) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
728 |
Universe::print_compressed_oops_mode(st); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
729 |
if (UseCompressedClassPointers) { |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
730 |
Metaspace::print_compressed_class_space(st); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
731 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
732 |
st->cr(); |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
733 |
} |
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
734 |
|
1 | 735 |
STEP(190, "(printing heap information)" ) |
736 |
||
737 |
if (_verbose && Universe::is_fully_initialized()) { |
|
16685
41c34debcde0
8011872: Include Bit Map addresses in the hs_err files
stefank
parents:
15602
diff
changeset
|
738 |
Universe::heap()->print_on_error(st); |
12268 | 739 |
st->cr(); |
740 |
||
741 |
st->print_cr("Polling page: " INTPTR_FORMAT, os::get_polling_page()); |
|
742 |
st->cr(); |
|
1 | 743 |
} |
744 |
||
7108 | 745 |
STEP(195, "(printing code cache information)" ) |
746 |
||
747 |
if (_verbose && Universe::is_fully_initialized()) { |
|
748 |
// print code cache information before vm abort |
|
15201
f3d755b11424
8005204: Code Cache Reduction: command line options implementation
vladidan
parents:
14477
diff
changeset
|
749 |
CodeCache::print_summary(st); |
7108 | 750 |
st->cr(); |
751 |
} |
|
752 |
||
11636
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
753 |
STEP(200, "(printing ring buffers)" ) |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
754 |
|
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
755 |
if (_verbose) { |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
756 |
Events::print_all(st); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
757 |
st->cr(); |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
758 |
} |
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
759 |
|
3c07b54482a5
7141200: log some interesting information in ring buffers for crashes
never
parents:
11483
diff
changeset
|
760 |
STEP(205, "(printing dynamic libraries)" ) |
1 | 761 |
|
762 |
if (_verbose) { |
|
763 |
// dynamic libraries, or memory map |
|
764 |
os::print_dll_info(st); |
|
765 |
st->cr(); |
|
766 |
} |
|
767 |
||
768 |
STEP(210, "(printing VM options)" ) |
|
769 |
||
770 |
if (_verbose) { |
|
771 |
// VM options |
|
772 |
Arguments::print_on(st); |
|
773 |
st->cr(); |
|
774 |
} |
|
775 |
||
12095 | 776 |
STEP(215, "(printing warning if internal testing API used)" ) |
777 |
||
778 |
if (WhiteBox::used()) { |
|
779 |
st->print_cr("Unsupported internal testing APIs have been used."); |
|
780 |
st->cr(); |
|
781 |
} |
|
782 |
||
1 | 783 |
STEP(220, "(printing environment variables)" ) |
784 |
||
785 |
if (_verbose) { |
|
30125 | 786 |
os::print_environment_variables(st, env_list); |
1 | 787 |
st->cr(); |
788 |
} |
|
789 |
||
790 |
STEP(225, "(printing signal handlers)" ) |
|
791 |
||
792 |
if (_verbose) { |
|
793 |
os::print_signal_handlers(st, buf, sizeof(buf)); |
|
794 |
st->cr(); |
|
795 |
} |
|
796 |
||
25946 | 797 |
STEP(228, "(Native Memory Tracking)" ) |
798 |
if (_verbose) { |
|
27162
0a4a7276949b
8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
coleenp
parents:
26821
diff
changeset
|
799 |
MemTracker::error_report(st); |
25946 | 800 |
} |
801 |
||
1 | 802 |
STEP(230, "" ) |
803 |
||
804 |
if (_verbose) { |
|
805 |
st->cr(); |
|
806 |
st->print_cr("--------------- S Y S T E M ---------------"); |
|
807 |
st->cr(); |
|
808 |
} |
|
809 |
||
810 |
STEP(240, "(printing OS information)" ) |
|
811 |
||
812 |
if (_verbose) { |
|
813 |
os::print_os_info(st); |
|
814 |
st->cr(); |
|
815 |
} |
|
816 |
||
817 |
STEP(250, "(printing CPU info)" ) |
|
818 |
if (_verbose) { |
|
819 |
os::print_cpu_info(st); |
|
820 |
st->cr(); |
|
821 |
} |
|
822 |
||
823 |
STEP(260, "(printing memory info)" ) |
|
824 |
||
825 |
if (_verbose) { |
|
826 |
os::print_memory_info(st); |
|
827 |
st->cr(); |
|
828 |
} |
|
829 |
||
830 |
STEP(270, "(printing internal vm info)" ) |
|
831 |
||
832 |
if (_verbose) { |
|
833 |
st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); |
|
834 |
st->cr(); |
|
835 |
} |
|
836 |
||
837 |
STEP(280, "(printing date and time)" ) |
|
838 |
||
839 |
if (_verbose) { |
|
31335
60081f497e75
8035074: hs_err improvement: Add time zone information in the hs_err file
coleenp
parents:
30773
diff
changeset
|
840 |
os::print_date_and_time(st, buf, sizeof(buf)); |
1 | 841 |
st->cr(); |
842 |
} |
|
843 |
||
28943
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
844 |
#ifndef PRODUCT |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
845 |
// print a defined marker to show that error handling finished correctly. |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
846 |
STEP(290, "(printing end marker)" ) |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
847 |
|
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
848 |
if (_verbose) { |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
849 |
st->print_cr("END."); |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
850 |
} |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
851 |
#endif |
679546f0cc1f
8065895: Synchronous signals during error reporting may terminate or hang VM process
dholmes
parents:
28513
diff
changeset
|
852 |
|
1 | 853 |
END |
854 |
||
855 |
# undef BEGIN |
|
856 |
# undef STEP |
|
857 |
# undef END |
|
858 |
} |
|
859 |
||
6176
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
860 |
VMError* volatile VMError::first_error = NULL; |
4d9030fe341f
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
5547
diff
changeset
|
861 |
volatile jlong VMError::first_error_tid = -1; |
1 | 862 |
|
18487
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
863 |
// An error could happen before tty is initialized or after it has been |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
864 |
// destroyed. Here we use a very simple unbuffered fdStream for printing. |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
865 |
// Only out.print_raw() and out.print_raw_cr() should be used, as other |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
866 |
// printing methods need to allocate large buffer on stack. To format a |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
867 |
// string, use jio_snprintf() with a static buffer or use staticBufferStream. |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
868 |
fdStream VMError::out(defaultStream::output_fd()); |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
869 |
fdStream VMError::log; // error log used by VMError::report_and_die() |
270ef05ebce8
7060111: race condition in VMError::report_and_die()
fparain
parents:
17134
diff
changeset
|
870 |
|
17121
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
871 |
/** Expand a pattern into a buffer starting at pos and open a file using constructed path */ |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
872 |
static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
873 |
int fd = -1; |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
874 |
if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) { |
28513
9464a1b5c184
8050807: Better performing performance data handling
gthornbr
parents:
27471
diff
changeset
|
875 |
// the O_EXCL flag will cause the open to fail if the file exists |
9464a1b5c184
8050807: Better performing performance data handling
gthornbr
parents:
27471
diff
changeset
|
876 |
fd = open(buf, O_RDWR | O_CREAT | O_EXCL, 0666); |
17121
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
877 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
878 |
return fd; |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
879 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
880 |
|
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
881 |
/** |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
882 |
* Construct file name for a log file and return it's file descriptor. |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
883 |
* Name and location depends on pattern, default_pattern params and access |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
884 |
* permissions. |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
885 |
*/ |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
886 |
static int prepare_log_file(const char* pattern, const char* default_pattern, char* buf, size_t buflen) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
887 |
int fd = -1; |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
888 |
|
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
889 |
// If possible, use specified pattern to construct log file name |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
890 |
if (pattern != NULL) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
891 |
fd = expand_and_open(pattern, buf, buflen, 0); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
892 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
893 |
|
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
894 |
// Either user didn't specify, or the user's location failed, |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
895 |
// so use the default name in the current directory |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
896 |
if (fd == -1) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
897 |
const char* cwd = os::get_current_directory(buf, buflen); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
898 |
if (cwd != NULL) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
899 |
size_t pos = strlen(cwd); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
900 |
int fsep_len = jio_snprintf(&buf[pos], buflen-pos, "%s", os::file_separator()); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
901 |
pos += fsep_len; |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
902 |
if (fsep_len > 0) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
903 |
fd = expand_and_open(default_pattern, buf, buflen, pos); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
904 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
905 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
906 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
907 |
|
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
908 |
// try temp directory if it exists. |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
909 |
if (fd == -1) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
910 |
const char* tmpdir = os::get_temp_directory(); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
911 |
if (tmpdir != NULL && strlen(tmpdir) > 0) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
912 |
int pos = jio_snprintf(buf, buflen, "%s%s", tmpdir, os::file_separator()); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
913 |
if (pos > 0) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
914 |
fd = expand_and_open(default_pattern, buf, buflen, pos); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
915 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
916 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
917 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
918 |
|
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
919 |
return fd; |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
920 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
921 |
|
1 | 922 |
void VMError::report_and_die() { |
923 |
// Don't allocate large buffer on stack |
|
924 |
static char buffer[O_BUFLEN]; |
|
925 |
||
926 |
// How many errors occurred in error handler when reporting first_error. |
|
927 |
static int recursive_error_count; |
|
928 |
||
929 |
// We will first print a brief message to standard out (verbose = false), |
|
930 |
// then save detailed information in log file (verbose = true). |
|
931 |
static bool out_done = false; // done printing to standard out |
|
932 |
static bool log_done = false; // done saving error log |
|
8114
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
933 |
static bool transmit_report_done = false; // done error reporting |
1 | 934 |
|
935 |
if (SuppressFatalErrorMessage) { |
|
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
936 |
os::abort(CreateCoredumpOnCrash); |
1 | 937 |
} |
938 |
jlong mytid = os::current_thread_id(); |
|
939 |
if (first_error == NULL && |
|
940 |
Atomic::cmpxchg_ptr(this, &first_error, NULL) == NULL) { |
|
941 |
||
942 |
// first time |
|
943 |
first_error_tid = mytid; |
|
944 |
set_error_reported(); |
|
945 |
||
8476
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
946 |
if (ShowMessageBoxOnError || PauseAtExit) { |
1 | 947 |
show_message_box(buffer, sizeof(buffer)); |
948 |
||
949 |
// User has asked JVM to abort. Reset ShowMessageBoxOnError so the |
|
950 |
// WatcherThread can kill JVM if the error handler hangs. |
|
951 |
ShowMessageBoxOnError = false; |
|
952 |
} |
|
953 |
||
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
954 |
os::check_dump_limit(buffer, sizeof(buffer)); |
8119
81eef1b06988
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
8114
diff
changeset
|
955 |
|
1 | 956 |
// reset signal handlers or exception filter; make sure recursive crashes |
957 |
// are handled properly. |
|
958 |
reset_signal_handlers(); |
|
959 |
||
960 |
} else { |
|
1887
0ed88ac17540
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
1660
diff
changeset
|
961 |
// If UseOsErrorReporting we call this for each level of the call stack |
0ed88ac17540
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
1660
diff
changeset
|
962 |
// while searching for the exception handler. Only the first level needs |
0ed88ac17540
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
1660
diff
changeset
|
963 |
// to be reported. |
0ed88ac17540
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
1660
diff
changeset
|
964 |
if (UseOSErrorReporting && log_done) return; |
0ed88ac17540
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
1660
diff
changeset
|
965 |
|
1 | 966 |
// This is not the first error, see if it happened in a different thread |
967 |
// or in the same thread during error reporting. |
|
968 |
if (first_error_tid != mytid) { |
|
18684 | 969 |
char msgbuf[64]; |
970 |
jio_snprintf(msgbuf, sizeof(msgbuf), |
|
1 | 971 |
"[thread " INT64_FORMAT " also had an error]", |
972 |
mytid); |
|
18684 | 973 |
out.print_raw_cr(msgbuf); |
1 | 974 |
|
975 |
// error reporting is not MT-safe, block current thread |
|
976 |
os::infinite_sleep(); |
|
977 |
||
978 |
} else { |
|
979 |
if (recursive_error_count++ > 30) { |
|
980 |
out.print_raw_cr("[Too many errors, abort]"); |
|
981 |
os::die(); |
|
982 |
} |
|
983 |
||
984 |
jio_snprintf(buffer, sizeof(buffer), |
|
985 |
"[error occurred during error reporting %s, id 0x%x]", |
|
986 |
first_error ? first_error->_current_step_info : "", |
|
987 |
_id); |
|
988 |
if (log.is_open()) { |
|
989 |
log.cr(); |
|
990 |
log.print_raw_cr(buffer); |
|
991 |
log.cr(); |
|
992 |
} else { |
|
993 |
out.cr(); |
|
994 |
out.print_raw_cr(buffer); |
|
995 |
out.cr(); |
|
996 |
} |
|
997 |
} |
|
998 |
} |
|
999 |
||
1000 |
// print to screen |
|
1001 |
if (!out_done) { |
|
1002 |
first_error->_verbose = false; |
|
1003 |
||
1004 |
staticBufferStream sbs(buffer, sizeof(buffer), &out); |
|
1005 |
first_error->report(&sbs); |
|
1006 |
||
1007 |
out_done = true; |
|
1008 |
||
1009 |
first_error->_current_step = 0; // reset current_step |
|
1010 |
first_error->_current_step_info = ""; // reset current_step string |
|
1011 |
} |
|
1012 |
||
1013 |
// print to error log file |
|
1014 |
if (!log_done) { |
|
1015 |
first_error->_verbose = true; |
|
1016 |
||
1017 |
// see if log file is already open |
|
1018 |
if (!log.is_open()) { |
|
1019 |
// open log file |
|
17121
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1020 |
int fd = prepare_log_file(ErrorFile, "hs_err_pid%p.log", buffer, sizeof(buffer)); |
1 | 1021 |
if (fd != -1) { |
1022 |
out.print_raw("# An error report file with more information is saved as:\n# "); |
|
1023 |
out.print_raw_cr(buffer); |
|
1024 |
||
1025 |
log.set_fd(fd); |
|
1026 |
} else { |
|
1027 |
out.print_raw_cr("# Can not save log file, dump to screen.."); |
|
1028 |
log.set_fd(defaultStream::output_fd()); |
|
8114
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1029 |
/* Error reporting currently needs dumpfile. |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1030 |
* Maybe implement direct streaming in the future.*/ |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1031 |
transmit_report_done = true; |
1 | 1032 |
} |
1033 |
} |
|
1034 |
||
1035 |
staticBufferStream sbs(buffer, O_BUFLEN, &log); |
|
1036 |
first_error->report(&sbs); |
|
1037 |
first_error->_current_step = 0; // reset current_step |
|
1038 |
first_error->_current_step_info = ""; // reset current_step string |
|
1039 |
||
8114
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1040 |
// Run error reporting to determine whether or not to report the crash. |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1041 |
if (!transmit_report_done && should_report_bug(first_error->_id)) { |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1042 |
transmit_report_done = true; |
27471 | 1043 |
const int fd2 = ::dup(log.fd()); |
1044 |
FILE* const hs_err = ::fdopen(fd2, "r"); |
|
8114
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1045 |
if (NULL != hs_err) { |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1046 |
ErrorReporter er; |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1047 |
er.call(hs_err, buffer, O_BUFLEN); |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1048 |
} |
27471 | 1049 |
::fclose(hs_err); |
8114
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1050 |
} |
340b5b8b544b
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
7901
diff
changeset
|
1051 |
|
1 | 1052 |
if (log.fd() != defaultStream::output_fd()) { |
1053 |
close(log.fd()); |
|
1054 |
} |
|
1055 |
||
1056 |
log.set_fd(-1); |
|
1057 |
log_done = true; |
|
1058 |
} |
|
1059 |
||
1060 |
||
1061 |
static bool skip_OnError = false; |
|
1062 |
if (!skip_OnError && OnError && OnError[0]) { |
|
1063 |
skip_OnError = true; |
|
1064 |
||
1065 |
out.print_raw_cr("#"); |
|
1066 |
out.print_raw ("# -XX:OnError=\""); |
|
1067 |
out.print_raw (OnError); |
|
1068 |
out.print_raw_cr("\""); |
|
1069 |
||
1070 |
char* cmd; |
|
1071 |
const char* ptr = OnError; |
|
1072 |
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ |
|
1073 |
out.print_raw ("# Executing "); |
|
10565 | 1074 |
#if defined(LINUX) || defined(_ALLBSD_SOURCE) |
1 | 1075 |
out.print_raw ("/bin/sh -c "); |
1076 |
#elif defined(SOLARIS) |
|
1077 |
out.print_raw ("/usr/bin/sh -c "); |
|
1078 |
#endif |
|
1079 |
out.print_raw ("\""); |
|
1080 |
out.print_raw (cmd); |
|
1081 |
out.print_raw_cr("\" ..."); |
|
1082 |
||
30745
8ebe80838174
8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
30622
diff
changeset
|
1083 |
if (os::fork_and_exec(cmd) < 0) { |
8ebe80838174
8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
30622
diff
changeset
|
1084 |
out.print_cr("os::fork_and_exec failed: %s (%d)", strerror(errno), errno); |
8ebe80838174
8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
30622
diff
changeset
|
1085 |
} |
1 | 1086 |
} |
1087 |
||
1088 |
// done with OnError |
|
1089 |
OnError = NULL; |
|
1090 |
} |
|
1091 |
||
22243 | 1092 |
static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14289
diff
changeset
|
1093 |
if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14289
diff
changeset
|
1094 |
skip_replay = true; |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14289
diff
changeset
|
1095 |
ciEnv* env = ciEnv::current(); |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14289
diff
changeset
|
1096 |
if (env != NULL) { |
17121
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1097 |
int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", buffer, sizeof(buffer)); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1098 |
if (fd != -1) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1099 |
FILE* replay_data_file = os::open(fd, "w"); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1100 |
if (replay_data_file != NULL) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1101 |
fileStream replay_data_stream(replay_data_file, /*need_close=*/true); |
20692
65021f70c2fc
8024943: ciReplay: fails to dump replay data during safepointing
vlivanov
parents:
19952
diff
changeset
|
1102 |
env->dump_replay_data_unsafe(&replay_data_stream); |
17121
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1103 |
out.print_raw("#\n# Compiler replay data is saved as:\n# "); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1104 |
out.print_raw_cr(buffer); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1105 |
} else { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1106 |
out.print_raw("#\n# Can't open file to dump replay data. Error: "); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1107 |
out.print_raw_cr(strerror(os::get_last_error())); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1108 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16685
diff
changeset
|
1109 |
} |
14477
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14289
diff
changeset
|
1110 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14289
diff
changeset
|
1111 |
} |
95e66ea71f71
6830717: replay of compilations would help with debugging
minqi
parents:
14289
diff
changeset
|
1112 |
|
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
1113 |
static bool skip_bug_url = !should_report_bug(first_error->_id); |
1 | 1114 |
if (!skip_bug_url) { |
1115 |
skip_bug_url = true; |
|
1116 |
||
1117 |
out.print_raw_cr("#"); |
|
1118 |
print_bug_submit_message(&out, _thread); |
|
1119 |
} |
|
1120 |
||
1121 |
if (!UseOSErrorReporting) { |
|
1122 |
// os::abort() will call abort hooks, try it first. |
|
1123 |
static bool skip_os_abort = false; |
|
1124 |
if (!skip_os_abort) { |
|
1125 |
skip_os_abort = true; |
|
7719
ef138e2849eb
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
7447
diff
changeset
|
1126 |
bool dump_core = should_report_bug(first_error->_id); |
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
30125
diff
changeset
|
1127 |
os::abort(dump_core && CreateCoredumpOnCrash, _siginfo, _context); |
1 | 1128 |
} |
1129 |
||
1130 |
// if os::abort() doesn't abort, try os::die(); |
|
1131 |
os::die(); |
|
1132 |
} |
|
1133 |
} |
|
1134 |
||
1135 |
/* |
|
1136 |
* OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this |
|
1137 |
* ensures utilities such as jmap can observe the process is a consistent state. |
|
1138 |
*/ |
|
1139 |
class VM_ReportJavaOutOfMemory : public VM_Operation { |
|
1140 |
private: |
|
1141 |
VMError *_err; |
|
1142 |
public: |
|
1143 |
VM_ReportJavaOutOfMemory(VMError *err) { _err = err; } |
|
1144 |
VMOp_Type type() const { return VMOp_ReportJavaOutOfMemory; } |
|
1145 |
void doit(); |
|
1146 |
}; |
|
1147 |
||
1148 |
void VM_ReportJavaOutOfMemory::doit() { |
|
1149 |
// Don't allocate large buffer on stack |
|
1150 |
static char buffer[O_BUFLEN]; |
|
1151 |
||
1152 |
tty->print_cr("#"); |
|
1153 |
tty->print_cr("# java.lang.OutOfMemoryError: %s", _err->message()); |
|
1154 |
tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError); |
|
1155 |
||
1156 |
// make heap parsability |
|
1157 |
Universe::heap()->ensure_parsability(false); // no need to retire TLABs |
|
1158 |
||
1159 |
char* cmd; |
|
1160 |
const char* ptr = OnOutOfMemoryError; |
|
1161 |
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ |
|
1162 |
tty->print("# Executing "); |
|
1163 |
#if defined(LINUX) |
|
1164 |
tty->print ("/bin/sh -c "); |
|
1165 |
#elif defined(SOLARIS) |
|
1166 |
tty->print ("/usr/bin/sh -c "); |
|
1167 |
#endif |
|
1168 |
tty->print_cr("\"%s\"...", cmd); |
|
1169 |
||
30745
8ebe80838174
8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
30622
diff
changeset
|
1170 |
if (os::fork_and_exec(cmd) < 0) { |
8ebe80838174
8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
30622
diff
changeset
|
1171 |
tty->print_cr("os::fork_and_exec failed: %s (%d)", strerror(errno), errno); |
8ebe80838174
8078470: [Linux] Replace syscall use in os::fork_and_exec with glibc fork() and execve()
dholmes
parents:
30622
diff
changeset
|
1172 |
} |
1 | 1173 |
} |
1174 |
} |
|
1175 |
||
1176 |
void VMError::report_java_out_of_memory() { |
|
1177 |
if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { |
|
1178 |
MutexLocker ml(Heap_lock); |
|
1179 |
VM_ReportJavaOutOfMemory op(this); |
|
1180 |
VMThread::execute(&op); |
|
1181 |
} |
|
1182 |
} |