Mercurial > hg > truffle
annotate src/share/vm/utilities/vmError.cpp @ 4990:2551ebf25ff9
slightly prefer inlining within loops
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Mon, 27 Feb 2012 19:15:30 -0800 |
parents | aa3d708d67c4 |
children | 2d503de963b3 |
rev | line source |
---|---|
0 | 1 /* |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1490
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "compiler/compileBroker.hpp" | |
27 #include "gc_interface/collectedHeap.hpp" | |
28 #include "runtime/arguments.hpp" | |
29 #include "runtime/frame.inline.hpp" | |
30 #include "runtime/init.hpp" | |
31 #include "runtime/os.hpp" | |
32 #include "runtime/thread.hpp" | |
33 #include "runtime/vmThread.hpp" | |
34 #include "runtime/vm_operations.hpp" | |
35 #include "utilities/debug.hpp" | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
1972
diff
changeset
|
36 #include "utilities/decoder.hpp" |
1972 | 37 #include "utilities/defaultStream.hpp" |
2199
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
38 #include "utilities/errorReporter.hpp" |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
39 #include "utilities/events.hpp" |
1972 | 40 #include "utilities/top.hpp" |
41 #include "utilities/vmError.hpp" | |
0 | 42 |
43 // List of environment variables that should be reported in error log file. | |
44 const char *env_list[] = { | |
45 // All platforms | |
46 "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH", | |
47 "JAVA_COMPILER", "PATH", "USERNAME", | |
48 | |
3960 | 49 // Env variables that are defined on Solaris/Linux/BSD |
0 | 50 "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY", |
51 "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE", | |
52 | |
53 // defined on Linux | |
54 "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM", | |
55 | |
3960 | 56 // defined on Darwin |
57 "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH", | |
58 "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH", | |
59 "DYLD_INSERT_LIBRARIES", | |
60 | |
0 | 61 // defined on Windows |
62 "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR", | |
63 | |
64 (const char *)0 | |
65 }; | |
66 | |
67 // Fatal error handler for internal errors and crashes. | |
68 // | |
69 // The default behavior of fatal error handler is to print a brief message | |
70 // to standard out (defaultStream::output_fd()), then save detailed information | |
71 // into an error report file (hs_err_pid<pid>.log) and abort VM. If multiple | |
72 // threads are having troubles at the same time, only one error is reported. | |
73 // The thread that is reporting error will abort VM when it is done, all other | |
74 // threads are blocked forever inside report_and_die(). | |
75 | |
76 // Constructor for crashes | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
77 VMError::VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context) { |
0 | 78 _thread = thread; |
79 _id = sig; | |
80 _pc = pc; | |
81 _siginfo = siginfo; | |
82 _context = context; | |
83 | |
84 _verbose = false; | |
85 _current_step = 0; | |
86 _current_step_info = NULL; | |
87 | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
88 _message = NULL; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
89 _detail_msg = NULL; |
0 | 90 _filename = NULL; |
91 _lineno = 0; | |
92 | |
93 _size = 0; | |
94 } | |
95 | |
96 // Constructor for internal errors | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
97 VMError::VMError(Thread* thread, const char* filename, int lineno, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
98 const char* message, const char * detail_msg) |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
99 { |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
100 _thread = thread; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
101 _id = internal_error; // Value that's not an OS exception/signal |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
102 _filename = filename; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
103 _lineno = lineno; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
104 _message = message; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
105 _detail_msg = detail_msg; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
106 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
107 _verbose = false; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
108 _current_step = 0; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
109 _current_step_info = NULL; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
110 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
111 _pc = NULL; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
112 _siginfo = NULL; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
113 _context = NULL; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
114 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
115 _size = 0; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
116 } |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
117 |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
118 // Constructor for OOM errors |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
119 VMError::VMError(Thread* thread, const char* filename, int lineno, size_t size, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
120 const char* message) { |
0 | 121 _thread = thread; |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
122 _id = oom_error; // Value that's not an OS exception/signal |
0 | 123 _filename = filename; |
124 _lineno = lineno; | |
125 _message = message; | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
126 _detail_msg = NULL; |
0 | 127 |
128 _verbose = false; | |
129 _current_step = 0; | |
130 _current_step_info = NULL; | |
131 | |
132 _pc = NULL; | |
133 _siginfo = NULL; | |
134 _context = NULL; | |
135 | |
136 _size = size; | |
137 } | |
138 | |
139 | |
140 // Constructor for non-fatal errors | |
141 VMError::VMError(const char* message) { | |
142 _thread = NULL; | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
143 _id = internal_error; // Value that's not an OS exception/signal |
0 | 144 _filename = NULL; |
145 _lineno = 0; | |
146 _message = message; | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
147 _detail_msg = NULL; |
0 | 148 |
149 _verbose = false; | |
150 _current_step = 0; | |
151 _current_step_info = NULL; | |
152 | |
153 _pc = NULL; | |
154 _siginfo = NULL; | |
155 _context = NULL; | |
156 | |
157 _size = 0; | |
158 } | |
159 | |
160 // -XX:OnError=<string>, where <string> can be a list of commands, separated | |
161 // by ';'. "%p" is replaced by current process id (pid); "%%" is replaced by | |
162 // a single "%". Some examples: | |
163 // | |
164 // -XX:OnError="pmap %p" // show memory map | |
165 // -XX:OnError="gcore %p; dbx - %p" // dump core and launch debugger | |
166 // -XX:OnError="cat hs_err_pid%p.log | mail my_email@sun.com" | |
167 // -XX:OnError="kill -9 %p" // ?#!@# | |
168 | |
169 // A simple parser for -XX:OnError, usage: | |
170 // ptr = OnError; | |
171 // while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr) != NULL) | |
172 // ... ... | |
173 static char* next_OnError_command(char* buf, int buflen, const char** ptr) { | |
174 if (ptr == NULL || *ptr == NULL) return NULL; | |
175 | |
176 const char* cmd = *ptr; | |
177 | |
178 // skip leading blanks or ';' | |
179 while (*cmd == ' ' || *cmd == ';') cmd++; | |
180 | |
181 if (*cmd == '\0') return NULL; | |
182 | |
183 const char * cmdend = cmd; | |
184 while (*cmdend != '\0' && *cmdend != ';') cmdend++; | |
185 | |
186 Arguments::copy_expand_pid(cmd, cmdend - cmd, buf, buflen); | |
187 | |
188 *ptr = (*cmdend == '\0' ? cmdend : cmdend + 1); | |
189 return buf; | |
190 } | |
191 | |
192 | |
193 static void print_bug_submit_message(outputStream *out, Thread *thread) { | |
194 if (out == NULL) return; | |
195 out->print_raw_cr("# If you would like to submit a bug report, please visit:"); | |
196 out->print_raw ("# "); | |
197 out->print_raw_cr(Arguments::java_vendor_url_bug()); | |
198 // If the crash is in native code, encourage user to submit a bug to the | |
199 // provider of that code. | |
56
31d829b33f26
6549844: Wording problems in "An unexpected error ..."
coleenp
parents:
0
diff
changeset
|
200 if (thread && thread->is_Java_thread() && |
31d829b33f26
6549844: Wording problems in "An unexpected error ..."
coleenp
parents:
0
diff
changeset
|
201 !thread->is_hidden_from_external_view()) { |
0 | 202 JavaThread* jt = (JavaThread*)thread; |
203 if (jt->thread_state() == _thread_in_native) { | |
204 out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug."); | |
205 } | |
206 } | |
207 out->print_raw_cr("#"); | |
208 } | |
209 | |
2204
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
210 bool VMError::coredump_status; |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
211 char VMError::coredump_message[O_BUFLEN]; |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
212 |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
213 void VMError::report_coredump_status(const char* message, bool status) { |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
214 coredump_status = status; |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
215 strncpy(coredump_message, message, sizeof(coredump_message)); |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
216 coredump_message[sizeof(coredump_message)-1] = 0; |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
217 } |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
218 |
0 | 219 |
220 // Return a string to describe the error | |
221 char* VMError::error_string(char* buf, int buflen) { | |
222 char signame_buf[64]; | |
223 const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf)); | |
224 | |
225 if (signame) { | |
226 jio_snprintf(buf, buflen, | |
227 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, | |
228 signame, _id, _pc, | |
229 os::current_process_id(), os::current_thread_id()); | |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
230 } else if (_filename != NULL && _lineno > 0) { |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
231 // skip directory names |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
232 char separator = os::file_separator()[0]; |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
233 const char *p = strrchr(_filename, separator); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
234 int n = jio_snprintf(buf, buflen, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
235 "Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
236 p ? p + 1 : _filename, _lineno, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
237 os::current_process_id(), os::current_thread_id()); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
238 if (n >= 0 && n < buflen && _message) { |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
239 if (_detail_msg) { |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
240 jio_snprintf(buf + n, buflen - n, "%s%s: %s", |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
241 os::line_separator(), _message, _detail_msg); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
242 } else { |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
243 jio_snprintf(buf + n, buflen - n, "%sError: %s", |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
244 os::line_separator(), _message); |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
245 } |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
246 } |
0 | 247 } else { |
1490
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
248 jio_snprintf(buf, buflen, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
249 "Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT, |
f03d0a26bf83
6888954: argument formatting for assert() and friends
jcoomes
parents:
1384
diff
changeset
|
250 _id, os::current_process_id(), os::current_thread_id()); |
0 | 251 } |
252 | |
253 return buf; | |
254 } | |
255 | |
1384 | 256 void VMError::print_stack_trace(outputStream* st, JavaThread* jt, |
257 char* buf, int buflen, bool verbose) { | |
258 #ifdef ZERO | |
259 if (jt->zero_stack()->sp() && jt->top_zero_frame()) { | |
260 // StackFrameStream uses the frame anchor, which may not have | |
261 // been set up. This can be done at any time in Zero, however, | |
262 // so if it hasn't been set up then we just set it up now and | |
263 // clear it again when we're done. | |
264 bool has_last_Java_frame = jt->has_last_Java_frame(); | |
265 if (!has_last_Java_frame) | |
266 jt->set_last_Java_frame(); | |
267 st->print("Java frames:"); | |
268 | |
269 // If the top frame is a Shark frame and the frame anchor isn't | |
270 // set up then it's possible that the information in the frame | |
271 // is garbage: it could be from a previous decache, or it could | |
272 // simply have never been written. So we print a warning... | |
273 StackFrameStream sfs(jt); | |
274 if (!has_last_Java_frame && !sfs.is_done()) { | |
275 if (sfs.current()->zeroframe()->is_shark_frame()) { | |
276 st->print(" (TOP FRAME MAY BE JUNK)"); | |
277 } | |
278 } | |
279 st->cr(); | |
280 | |
281 // Print the frames | |
282 for(int i = 0; !sfs.is_done(); sfs.next(), i++) { | |
283 sfs.current()->zero_print_on_error(i, st, buf, buflen); | |
284 st->cr(); | |
285 } | |
286 | |
287 // Reset the frame anchor if necessary | |
288 if (!has_last_Java_frame) | |
289 jt->reset_last_Java_frame(); | |
290 } | |
291 #else | |
292 if (jt->has_last_Java_frame()) { | |
293 st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); | |
294 for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { | |
295 sfs.current()->print_on_error(st, buf, buflen, verbose); | |
296 st->cr(); | |
297 } | |
298 } | |
299 #endif // ZERO | |
300 } | |
0 | 301 |
302 // This is the main function to report a fatal error. Only one thread can | |
303 // call this function, so we don't need to worry about MT-safety. But it's | |
304 // possible that the error handler itself may crash or die on an internal | |
305 // error, for example, when the stack/heap is badly damaged. We must be | |
306 // able to handle recursive errors that happen inside error handler. | |
307 // | |
308 // Error reporting is done in several steps. If a crash or internal error | |
309 // occurred when reporting an error, the nested signal/exception handler | |
310 // can skip steps that are already (or partially) done. Error reporting will | |
311 // continue from the next step. This allows us to retrieve and print | |
312 // information that may be unsafe to get after a fatal error. If it happens, | |
313 // you may find nested report_and_die() frames when you look at the stack | |
314 // in a debugger. | |
315 // | |
316 // In general, a hang in error handler is much worse than a crash or internal | |
317 // error, as it's harder to recover from a hang. Deadlock can happen if we | |
318 // try to grab a lock that is already owned by current thread, or if the | |
319 // owner is blocked forever (e.g. in os::infinite_sleep()). If possible, the | |
320 // error handler and all the functions it called should avoid grabbing any | |
321 // lock. An important thing to notice is that memory allocation needs a lock. | |
322 // | |
323 // We should avoid using large stack allocated buffers. Many errors happen | |
324 // when stack space is already low. Making things even worse is that there | |
325 // could be nested report_and_die() calls on stack (see above). Only one | |
326 // thread can report error, so large buffers are statically allocated in data | |
327 // segment. | |
328 | |
329 void VMError::report(outputStream* st) { | |
330 # define BEGIN if (_current_step == 0) { _current_step = 1; | |
331 # define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s; | |
332 # define END } | |
333 | |
334 // don't allocate large buffer on stack | |
335 static char buf[O_BUFLEN]; | |
336 | |
337 BEGIN | |
338 | |
56
31d829b33f26
6549844: Wording problems in "An unexpected error ..."
coleenp
parents:
0
diff
changeset
|
339 STEP(10, "(printing fatal error message)") |
0 | 340 |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
341 st->print_cr("#"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
342 if (should_report_bug(_id)) { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
343 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
344 } else { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
345 st->print_cr("# There is insufficient memory for the Java " |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
346 "Runtime Environment to continue."); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
347 } |
0 | 348 |
349 STEP(15, "(printing type of error)") | |
350 | |
351 switch(_id) { | |
352 case oom_error: | |
353 if (_size) { | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
354 st->print("# Native memory allocation (malloc) failed to allocate "); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
355 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size); |
0 | 356 st->print(buf); |
357 st->print(" bytes"); | |
358 if (_message != NULL) { | |
359 st->print(" for "); | |
360 st->print(_message); | |
361 } | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
362 st->cr(); |
0 | 363 } else { |
364 if (_message != NULL) | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
365 st->print("# "); |
0 | 366 st->print_cr(_message); |
367 } | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
368 // In error file give some solutions |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
369 if (_verbose) { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
370 st->print_cr("# Possible reasons:"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
371 st->print_cr("# The system is out of physical RAM or swap space"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
372 st->print_cr("# In 32 bit mode, the process size limit was hit"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
373 st->print_cr("# Possible solutions:"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
374 st->print_cr("# Reduce memory load on the system"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
375 st->print_cr("# Increase physical memory or swap space"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
376 st->print_cr("# Check if swap backing store is full"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
377 st->print_cr("# Use 64 bit Java on a 64 bit OS"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
378 st->print_cr("# Decrease Java heap size (-Xmx/-Xms)"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
379 st->print_cr("# Decrease number of Java threads"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
380 st->print_cr("# Decrease Java thread stack sizes (-Xss)"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
381 st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize="); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
382 st->print_cr("# This output file may be truncated or incomplete."); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
383 } else { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
384 return; // that's enough for the screen |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
385 } |
0 | 386 break; |
387 case internal_error: | |
388 default: | |
389 break; | |
390 } | |
391 | |
392 STEP(20, "(printing exception/signal name)") | |
393 | |
394 st->print_cr("#"); | |
395 st->print("# "); | |
396 // Is it an OS exception/signal? | |
397 if (os::exception_name(_id, buf, sizeof(buf))) { | |
398 st->print("%s", buf); | |
399 st->print(" (0x%x)", _id); // signal number | |
400 st->print(" at pc=" PTR_FORMAT, _pc); | |
401 } else { | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
402 if (should_report_bug(_id)) { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
403 st->print("Internal Error"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
404 } else { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
405 st->print("Out of Memory Error"); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
406 } |
0 | 407 if (_filename != NULL && _lineno > 0) { |
408 #ifdef PRODUCT | |
409 // In product mode chop off pathname? | |
410 char separator = os::file_separator()[0]; | |
411 const char *p = strrchr(_filename, separator); | |
412 const char *file = p ? p+1 : _filename; | |
413 #else | |
414 const char *file = _filename; | |
415 #endif | |
416 size_t len = strlen(file); | |
417 size_t buflen = sizeof(buf); | |
418 | |
419 strncpy(buf, file, buflen); | |
420 if (len + 10 < buflen) { | |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
511
diff
changeset
|
421 sprintf(buf + len, ":%d", _lineno); |
0 | 422 } |
423 st->print(" (%s)", buf); | |
424 } else { | |
425 st->print(" (0x%x)", _id); | |
426 } | |
427 } | |
428 | |
429 STEP(30, "(printing current thread and pid)") | |
430 | |
431 // process id, thread id | |
432 st->print(", pid=%d", os::current_process_id()); | |
433 st->print(", tid=" UINTX_FORMAT, os::current_thread_id()); | |
434 st->cr(); | |
435 | |
436 STEP(40, "(printing error message)") | |
437 | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
438 if (should_report_bug(_id)) { // already printed the message. |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
439 // error message |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
440 if (_detail_msg) { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
441 st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
442 } else if (_message) { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
443 st->print_cr("# Error: %s", _message); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
444 } |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
445 } |
0 | 446 |
447 STEP(50, "(printing Java version string)") | |
448 | |
449 // VM version | |
450 st->print_cr("#"); | |
473
3ad2b8576c4a
6689685: Hotspot crash error message should include libraries version
coleenp
parents:
420
diff
changeset
|
451 JDK_Version::current().to_string(buf, sizeof(buf)); |
3ad2b8576c4a
6689685: Hotspot crash error message should include libraries version
coleenp
parents:
420
diff
changeset
|
452 st->print_cr("# JRE version: %s", buf); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
56
diff
changeset
|
453 st->print_cr("# Java VM: %s (%s %s %s %s)", |
0 | 454 Abstract_VM_Version::vm_name(), |
455 Abstract_VM_Version::vm_release(), | |
456 Abstract_VM_Version::vm_info_string(), | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
56
diff
changeset
|
457 Abstract_VM_Version::vm_platform_string(), |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
56
diff
changeset
|
458 UseCompressedOops ? "compressed oops" : "" |
0 | 459 ); |
460 | |
461 STEP(60, "(printing problematic frame)") | |
462 | |
463 // Print current frame if we have a context (i.e. it's a crash) | |
464 if (_context) { | |
465 st->print_cr("# Problematic frame:"); | |
466 st->print("# "); | |
467 frame fr = os::fetch_frame_from_context(_context); | |
468 fr.print_on_error(st, buf, sizeof(buf)); | |
469 st->cr(); | |
470 st->print_cr("#"); | |
471 } | |
2204
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
472 STEP(63, "(printing core file information)") |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
473 st->print("# "); |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
474 if (coredump_status) { |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
475 st->print("Core dump written. Default location: %s", coredump_message); |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
476 } else { |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
477 st->print("Failed to write core dump. %s", coredump_message); |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
478 } |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
479 st->print_cr(""); |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
480 st->print_cr("#"); |
0 | 481 |
482 STEP(65, "(printing bug submit message)") | |
483 | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
484 if (should_report_bug(_id) && _verbose) { |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
485 print_bug_submit_message(st, _thread); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
486 } |
0 | 487 |
488 STEP(70, "(printing thread)" ) | |
489 | |
490 if (_verbose) { | |
491 st->cr(); | |
492 st->print_cr("--------------- T H R E A D ---------------"); | |
493 st->cr(); | |
494 } | |
495 | |
496 STEP(80, "(printing current thread)" ) | |
497 | |
498 // current thread | |
499 if (_verbose) { | |
500 if (_thread) { | |
501 st->print("Current thread (" PTR_FORMAT "): ", _thread); | |
502 _thread->print_on_error(st, buf, sizeof(buf)); | |
503 st->cr(); | |
504 } else { | |
505 st->print_cr("Current thread is native thread"); | |
506 } | |
507 st->cr(); | |
508 } | |
509 | |
510 STEP(90, "(printing siginfo)" ) | |
511 | |
512 // signal no, signal code, address that caused the fault | |
513 if (_verbose && _siginfo) { | |
514 os::print_siginfo(st, _siginfo); | |
515 st->cr(); | |
516 } | |
517 | |
518 STEP(100, "(printing registers, top of stack, instructions near pc)") | |
519 | |
520 // registers, top of stack, instructions near pc | |
521 if (_verbose && _context) { | |
522 os::print_context(st, _context); | |
523 st->cr(); | |
524 } | |
525 | |
1907 | 526 STEP(105, "(printing register info)") |
527 | |
528 // decode register contents if possible | |
529 if (_verbose && _context && Universe::is_fully_initialized()) { | |
530 os::print_register_info(st, _context); | |
531 st->cr(); | |
532 } | |
533 | |
0 | 534 STEP(110, "(printing stack bounds)" ) |
535 | |
536 if (_verbose) { | |
537 st->print("Stack: "); | |
538 | |
539 address stack_top; | |
540 size_t stack_size; | |
541 | |
542 if (_thread) { | |
543 stack_top = _thread->stack_base(); | |
544 stack_size = _thread->stack_size(); | |
545 } else { | |
546 stack_top = os::current_stack_base(); | |
547 stack_size = os::current_stack_size(); | |
548 } | |
549 | |
550 address stack_bottom = stack_top - stack_size; | |
551 st->print("[" PTR_FORMAT "," PTR_FORMAT "]", stack_bottom, stack_top); | |
552 | |
553 frame fr = _context ? os::fetch_frame_from_context(_context) | |
554 : os::current_frame(); | |
555 | |
556 if (fr.sp()) { | |
557 st->print(", sp=" PTR_FORMAT, fr.sp()); | |
1684
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
558 size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024); |
66c5dadb4d61
6973308: Missing zero length check before repne scas in check_klass_subtype_slow_path()
kvn
parents:
1552
diff
changeset
|
559 st->print(", free space=" SIZE_FORMAT "k", free_stack_size); |
0 | 560 } |
561 | |
562 st->cr(); | |
563 } | |
564 | |
565 STEP(120, "(printing native stack)" ) | |
566 | |
567 if (_verbose) { | |
568 frame fr = _context ? os::fetch_frame_from_context(_context) | |
569 : os::current_frame(); | |
570 | |
571 // see if it's a valid frame | |
572 if (fr.pc()) { | |
573 st->print_cr("Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)"); | |
574 | |
2022
2d4762ec74af
7003748: Decode C stack frames when symbols are presented (PhoneHome project)
zgu
parents:
1972
diff
changeset
|
575 |
0 | 576 int count = 0; |
577 while (count++ < StackPrintLimit) { | |
578 fr.print_on_error(st, buf, sizeof(buf)); | |
579 st->cr(); | |
580 if (os::is_first_C_frame(&fr)) break; | |
581 fr = os::get_sender_for_C_frame(&fr); | |
582 } | |
583 | |
584 if (count > StackPrintLimit) { | |
585 st->print_cr("...<more frames>..."); | |
586 } | |
587 | |
588 st->cr(); | |
589 } | |
590 } | |
591 | |
592 STEP(130, "(printing Java stack)" ) | |
593 | |
594 if (_verbose && _thread && _thread->is_Java_thread()) { | |
1384 | 595 print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf)); |
0 | 596 } |
597 | |
1119
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
598 STEP(135, "(printing target Java thread stack)" ) |
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
599 |
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
600 // printing Java thread stack trace if it is involved in GC crash |
1907 | 601 if (_verbose && _thread && (_thread->is_Named_thread())) { |
1119
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
602 JavaThread* jt = ((NamedThread *)_thread)->processed_thread(); |
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
603 if (jt != NULL) { |
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
604 st->print_cr("JavaThread " PTR_FORMAT " (nid = " UINTX_FORMAT ") was being processed", jt, jt->osthread()->thread_id()); |
1384 | 605 print_stack_trace(st, jt, buf, sizeof(buf), true); |
1119
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
606 } |
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
607 } |
547f81740344
6361589: Print out stack trace for target thread of GC crash
minqi
parents:
1010
diff
changeset
|
608 |
0 | 609 STEP(140, "(printing VM operation)" ) |
610 | |
611 if (_verbose && _thread && _thread->is_VM_thread()) { | |
612 VMThread* t = (VMThread*)_thread; | |
613 VM_Operation* op = t->vm_operation(); | |
614 if (op) { | |
615 op->print_on_error(st); | |
616 st->cr(); | |
617 st->cr(); | |
618 } | |
619 } | |
620 | |
621 STEP(150, "(printing current compile task)" ) | |
622 | |
623 if (_verbose && _thread && _thread->is_Compiler_thread()) { | |
624 CompilerThread* t = (CompilerThread*)_thread; | |
625 if (t->task()) { | |
626 st->cr(); | |
627 st->print_cr("Current CompileTask:"); | |
628 t->task()->print_line_on_error(st, buf, sizeof(buf)); | |
629 st->cr(); | |
630 } | |
631 } | |
632 | |
633 STEP(160, "(printing process)" ) | |
634 | |
635 if (_verbose) { | |
636 st->cr(); | |
637 st->print_cr("--------------- P R O C E S S ---------------"); | |
638 st->cr(); | |
639 } | |
640 | |
641 STEP(170, "(printing all threads)" ) | |
642 | |
643 // all threads | |
644 if (_verbose && _thread) { | |
645 Threads::print_on_error(st, _thread, buf, sizeof(buf)); | |
646 st->cr(); | |
647 } | |
648 | |
649 STEP(175, "(printing VM state)" ) | |
650 | |
651 if (_verbose) { | |
652 // Safepoint state | |
653 st->print("VM state:"); | |
654 | |
655 if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing"); | |
656 else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint"); | |
657 else st->print("not at safepoint"); | |
658 | |
659 // Also see if error occurred during initialization or shutdown | |
660 if (!Universe::is_fully_initialized()) { | |
661 st->print(" (not fully initialized)"); | |
662 } else if (VM_Exit::vm_exited()) { | |
663 st->print(" (shutting down)"); | |
664 } else { | |
665 st->print(" (normal execution)"); | |
666 } | |
667 st->cr(); | |
668 st->cr(); | |
669 } | |
670 | |
671 STEP(180, "(printing owned locks on error)" ) | |
672 | |
673 // mutexes/monitors that currently have an owner | |
674 if (_verbose) { | |
675 print_owned_locks_on_error(st); | |
676 st->cr(); | |
677 } | |
678 | |
679 STEP(190, "(printing heap information)" ) | |
680 | |
681 if (_verbose && Universe::is_fully_initialized()) { | |
4073
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
3960
diff
changeset
|
682 // Print heap information before vm abort. As we'd like as much |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
3960
diff
changeset
|
683 // information as possible in the report we ask for the |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
3960
diff
changeset
|
684 // extended (i.e., more detailed) version. |
53074c2c4600
7099849: G1: include heap region information in hs_err files
tonyp
parents:
3960
diff
changeset
|
685 Universe::print_on(st, true /* extended */); |
0 | 686 st->cr(); |
687 } | |
688 | |
1907 | 689 STEP(195, "(printing code cache information)" ) |
690 | |
691 if (_verbose && Universe::is_fully_initialized()) { | |
692 // print code cache information before vm abort | |
693 CodeCache::print_bounds(st); | |
694 st->cr(); | |
695 } | |
696 | |
4872
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
697 STEP(200, "(printing ring buffers)" ) |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
698 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
699 if (_verbose) { |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
700 Events::print_all(st); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
701 st->cr(); |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
702 } |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
703 |
aa3d708d67c4
7141200: log some interesting information in ring buffers for crashes
never
parents:
4803
diff
changeset
|
704 STEP(205, "(printing dynamic libraries)" ) |
0 | 705 |
706 if (_verbose) { | |
707 // dynamic libraries, or memory map | |
708 os::print_dll_info(st); | |
709 st->cr(); | |
710 } | |
711 | |
712 STEP(210, "(printing VM options)" ) | |
713 | |
714 if (_verbose) { | |
715 // VM options | |
716 Arguments::print_on(st); | |
717 st->cr(); | |
718 } | |
719 | |
720 STEP(220, "(printing environment variables)" ) | |
721 | |
722 if (_verbose) { | |
723 os::print_environment_variables(st, env_list, buf, sizeof(buf)); | |
724 st->cr(); | |
725 } | |
726 | |
727 STEP(225, "(printing signal handlers)" ) | |
728 | |
729 if (_verbose) { | |
730 os::print_signal_handlers(st, buf, sizeof(buf)); | |
731 st->cr(); | |
732 } | |
733 | |
734 STEP(230, "" ) | |
735 | |
736 if (_verbose) { | |
737 st->cr(); | |
738 st->print_cr("--------------- S Y S T E M ---------------"); | |
739 st->cr(); | |
740 } | |
741 | |
742 STEP(240, "(printing OS information)" ) | |
743 | |
744 if (_verbose) { | |
745 os::print_os_info(st); | |
746 st->cr(); | |
747 } | |
748 | |
749 STEP(250, "(printing CPU info)" ) | |
750 if (_verbose) { | |
751 os::print_cpu_info(st); | |
752 st->cr(); | |
753 } | |
754 | |
755 STEP(260, "(printing memory info)" ) | |
756 | |
757 if (_verbose) { | |
758 os::print_memory_info(st); | |
759 st->cr(); | |
760 } | |
761 | |
762 STEP(270, "(printing internal vm info)" ) | |
763 | |
764 if (_verbose) { | |
765 st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); | |
766 st->cr(); | |
767 } | |
768 | |
769 STEP(280, "(printing date and time)" ) | |
770 | |
771 if (_verbose) { | |
772 os::print_date_and_time(st); | |
773 st->cr(); | |
774 } | |
775 | |
776 END | |
777 | |
778 # undef BEGIN | |
779 # undef STEP | |
780 # undef END | |
781 } | |
782 | |
1681
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
783 VMError* volatile VMError::first_error = NULL; |
126ea7725993
6953477: Increase portability and flexibility of building Hotspot
bobv
parents:
1552
diff
changeset
|
784 volatile jlong VMError::first_error_tid = -1; |
0 | 785 |
786 void VMError::report_and_die() { | |
787 // Don't allocate large buffer on stack | |
788 static char buffer[O_BUFLEN]; | |
789 | |
790 // An error could happen before tty is initialized or after it has been | |
791 // destroyed. Here we use a very simple unbuffered fdStream for printing. | |
792 // Only out.print_raw() and out.print_raw_cr() should be used, as other | |
793 // printing methods need to allocate large buffer on stack. To format a | |
794 // string, use jio_snprintf() with a static buffer or use staticBufferStream. | |
795 static fdStream out(defaultStream::output_fd()); | |
796 | |
797 // How many errors occurred in error handler when reporting first_error. | |
798 static int recursive_error_count; | |
799 | |
800 // We will first print a brief message to standard out (verbose = false), | |
801 // then save detailed information in log file (verbose = true). | |
802 static bool out_done = false; // done printing to standard out | |
803 static bool log_done = false; // done saving error log | |
2199
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
804 static bool transmit_report_done = false; // done error reporting |
0 | 805 static fdStream log; // error log |
806 | |
807 if (SuppressFatalErrorMessage) { | |
808 os::abort(); | |
809 } | |
810 jlong mytid = os::current_thread_id(); | |
811 if (first_error == NULL && | |
812 Atomic::cmpxchg_ptr(this, &first_error, NULL) == NULL) { | |
813 | |
814 // first time | |
815 first_error_tid = mytid; | |
816 set_error_reported(); | |
817 | |
2302
da091bb67459
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
2204
diff
changeset
|
818 if (ShowMessageBoxOnError || PauseAtExit) { |
0 | 819 show_message_box(buffer, sizeof(buffer)); |
820 | |
821 // User has asked JVM to abort. Reset ShowMessageBoxOnError so the | |
822 // WatcherThread can kill JVM if the error handler hangs. | |
823 ShowMessageBoxOnError = false; | |
824 } | |
825 | |
2204
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
826 // Write a minidump on Windows, check core dump limits on Linux/Solaris |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
827 os::check_or_create_dump(_siginfo, _context, buffer, sizeof(buffer)); |
63d374c54045
7014918: Improve core/minidump handling in Hotspot
ctornqvi
parents:
2199
diff
changeset
|
828 |
0 | 829 // reset signal handlers or exception filter; make sure recursive crashes |
830 // are handled properly. | |
831 reset_signal_handlers(); | |
832 | |
833 } else { | |
511
dabd8d202164
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
473
diff
changeset
|
834 // If UseOsErrorReporting we call this for each level of the call stack |
dabd8d202164
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
473
diff
changeset
|
835 // while searching for the exception handler. Only the first level needs |
dabd8d202164
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
473
diff
changeset
|
836 // to be reported. |
dabd8d202164
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
473
diff
changeset
|
837 if (UseOSErrorReporting && log_done) return; |
dabd8d202164
4997835: RFE: crash dump will only be created when running w/ -XX:+ShowMessageBoxOnError
coleenp
parents:
473
diff
changeset
|
838 |
0 | 839 // This is not the first error, see if it happened in a different thread |
840 // or in the same thread during error reporting. | |
841 if (first_error_tid != mytid) { | |
842 jio_snprintf(buffer, sizeof(buffer), | |
843 "[thread " INT64_FORMAT " also had an error]", | |
844 mytid); | |
845 out.print_raw_cr(buffer); | |
846 | |
847 // error reporting is not MT-safe, block current thread | |
848 os::infinite_sleep(); | |
849 | |
850 } else { | |
851 if (recursive_error_count++ > 30) { | |
852 out.print_raw_cr("[Too many errors, abort]"); | |
853 os::die(); | |
854 } | |
855 | |
856 jio_snprintf(buffer, sizeof(buffer), | |
857 "[error occurred during error reporting %s, id 0x%x]", | |
858 first_error ? first_error->_current_step_info : "", | |
859 _id); | |
860 if (log.is_open()) { | |
861 log.cr(); | |
862 log.print_raw_cr(buffer); | |
863 log.cr(); | |
864 } else { | |
865 out.cr(); | |
866 out.print_raw_cr(buffer); | |
867 out.cr(); | |
868 } | |
869 } | |
870 } | |
871 | |
872 // print to screen | |
873 if (!out_done) { | |
874 first_error->_verbose = false; | |
875 | |
876 staticBufferStream sbs(buffer, sizeof(buffer), &out); | |
877 first_error->report(&sbs); | |
878 | |
879 out_done = true; | |
880 | |
881 first_error->_current_step = 0; // reset current_step | |
882 first_error->_current_step_info = ""; // reset current_step string | |
883 } | |
884 | |
885 // print to error log file | |
886 if (!log_done) { | |
887 first_error->_verbose = true; | |
888 | |
889 // see if log file is already open | |
890 if (!log.is_open()) { | |
891 // open log file | |
892 int fd = -1; | |
893 | |
894 if (ErrorFile != NULL) { | |
895 bool copy_ok = | |
896 Arguments::copy_expand_pid(ErrorFile, strlen(ErrorFile), buffer, sizeof(buffer)); | |
897 if (copy_ok) { | |
2199
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
898 fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); |
0 | 899 } |
900 } | |
901 | |
902 if (fd == -1) { | |
903 const char *cwd = os::get_current_directory(buffer, sizeof(buffer)); | |
904 size_t len = strlen(cwd); | |
905 // either user didn't specify, or the user's location failed, | |
906 // so use the default name in the current directory | |
907 jio_snprintf(&buffer[len], sizeof(buffer)-len, "%shs_err_pid%u.log", | |
908 os::file_separator(), os::current_process_id()); | |
2199
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
909 fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); |
0 | 910 } |
911 | |
912 if (fd == -1) { | |
913 const char * tmpdir = os::get_temp_directory(); | |
2130
34d64ad817f4
7009828: Fix for 6938627 breaks visualvm monitoring when -Djava.io.tmpdir is defined
coleenp
parents:
2095
diff
changeset
|
914 // try temp directory if it exists. |
34d64ad817f4
7009828: Fix for 6938627 breaks visualvm monitoring when -Djava.io.tmpdir is defined
coleenp
parents:
2095
diff
changeset
|
915 if (tmpdir != NULL && tmpdir[0] != '\0') { |
34d64ad817f4
7009828: Fix for 6938627 breaks visualvm monitoring when -Djava.io.tmpdir is defined
coleenp
parents:
2095
diff
changeset
|
916 jio_snprintf(buffer, sizeof(buffer), "%s%shs_err_pid%u.log", |
34d64ad817f4
7009828: Fix for 6938627 breaks visualvm monitoring when -Djava.io.tmpdir is defined
coleenp
parents:
2095
diff
changeset
|
917 tmpdir, os::file_separator(), os::current_process_id()); |
2199
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
918 fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); |
2130
34d64ad817f4
7009828: Fix for 6938627 breaks visualvm monitoring when -Djava.io.tmpdir is defined
coleenp
parents:
2095
diff
changeset
|
919 } |
0 | 920 } |
921 | |
922 if (fd != -1) { | |
923 out.print_raw("# An error report file with more information is saved as:\n# "); | |
924 out.print_raw_cr(buffer); | |
925 os::set_error_file(buffer); | |
926 | |
927 log.set_fd(fd); | |
928 } else { | |
929 out.print_raw_cr("# Can not save log file, dump to screen.."); | |
930 log.set_fd(defaultStream::output_fd()); | |
2199
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
931 /* Error reporting currently needs dumpfile. |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
932 * Maybe implement direct streaming in the future.*/ |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
933 transmit_report_done = true; |
0 | 934 } |
935 } | |
936 | |
937 staticBufferStream sbs(buffer, O_BUFLEN, &log); | |
938 first_error->report(&sbs); | |
939 first_error->_current_step = 0; // reset current_step | |
940 first_error->_current_step_info = ""; // reset current_step string | |
941 | |
2199
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
942 // Run error reporting to determine whether or not to report the crash. |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
943 if (!transmit_report_done && should_report_bug(first_error->_id)) { |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
944 transmit_report_done = true; |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
945 FILE* hs_err = ::fdopen(log.fd(), "r"); |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
946 if (NULL != hs_err) { |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
947 ErrorReporter er; |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
948 er.call(hs_err, buffer, O_BUFLEN); |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
949 } |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
950 } |
d8a72fbc4be7
7003401: Implement VM error-reporting functionality on erroneous termination
kamg
parents:
2130
diff
changeset
|
951 |
0 | 952 if (log.fd() != defaultStream::output_fd()) { |
953 close(log.fd()); | |
954 } | |
955 | |
956 log.set_fd(-1); | |
957 log_done = true; | |
958 } | |
959 | |
960 | |
961 static bool skip_OnError = false; | |
962 if (!skip_OnError && OnError && OnError[0]) { | |
963 skip_OnError = true; | |
964 | |
965 out.print_raw_cr("#"); | |
966 out.print_raw ("# -XX:OnError=\""); | |
967 out.print_raw (OnError); | |
968 out.print_raw_cr("\""); | |
969 | |
970 char* cmd; | |
971 const char* ptr = OnError; | |
972 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ | |
973 out.print_raw ("# Executing "); | |
3960 | 974 #if defined(LINUX) || defined(_ALLBSD_SOURCE) |
0 | 975 out.print_raw ("/bin/sh -c "); |
976 #elif defined(SOLARIS) | |
977 out.print_raw ("/usr/bin/sh -c "); | |
978 #endif | |
979 out.print_raw ("\""); | |
980 out.print_raw (cmd); | |
981 out.print_raw_cr("\" ..."); | |
982 | |
983 os::fork_and_exec(cmd); | |
984 } | |
985 | |
986 // done with OnError | |
987 OnError = NULL; | |
988 } | |
989 | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
990 static bool skip_bug_url = !should_report_bug(first_error->_id); |
0 | 991 if (!skip_bug_url) { |
992 skip_bug_url = true; | |
993 | |
994 out.print_raw_cr("#"); | |
995 print_bug_submit_message(&out, _thread); | |
996 } | |
997 | |
998 if (!UseOSErrorReporting) { | |
999 // os::abort() will call abort hooks, try it first. | |
1000 static bool skip_os_abort = false; | |
1001 if (!skip_os_abort) { | |
1002 skip_os_abort = true; | |
2095
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
1003 bool dump_core = should_report_bug(first_error->_id); |
36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
coleenp
parents:
2022
diff
changeset
|
1004 os::abort(dump_core); |
0 | 1005 } |
1006 | |
1007 // if os::abort() doesn't abort, try os::die(); | |
1008 os::die(); | |
1009 } | |
1010 } | |
1011 | |
1012 /* | |
1013 * OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this | |
1014 * ensures utilities such as jmap can observe the process is a consistent state. | |
1015 */ | |
1016 class VM_ReportJavaOutOfMemory : public VM_Operation { | |
1017 private: | |
1018 VMError *_err; | |
1019 public: | |
1020 VM_ReportJavaOutOfMemory(VMError *err) { _err = err; } | |
1021 VMOp_Type type() const { return VMOp_ReportJavaOutOfMemory; } | |
1022 void doit(); | |
1023 }; | |
1024 | |
1025 void VM_ReportJavaOutOfMemory::doit() { | |
1026 // Don't allocate large buffer on stack | |
1027 static char buffer[O_BUFLEN]; | |
1028 | |
1029 tty->print_cr("#"); | |
1030 tty->print_cr("# java.lang.OutOfMemoryError: %s", _err->message()); | |
1031 tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError); | |
1032 | |
1033 // make heap parsability | |
1034 Universe::heap()->ensure_parsability(false); // no need to retire TLABs | |
1035 | |
1036 char* cmd; | |
1037 const char* ptr = OnOutOfMemoryError; | |
1038 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ | |
1039 tty->print("# Executing "); | |
1040 #if defined(LINUX) | |
1041 tty->print ("/bin/sh -c "); | |
1042 #elif defined(SOLARIS) | |
1043 tty->print ("/usr/bin/sh -c "); | |
1044 #endif | |
1045 tty->print_cr("\"%s\"...", cmd); | |
1046 | |
1047 os::fork_and_exec(cmd); | |
1048 } | |
1049 } | |
1050 | |
1051 void VMError::report_java_out_of_memory() { | |
1052 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { | |
1053 MutexLocker ml(Heap_lock); | |
1054 VM_ReportJavaOutOfMemory op(this); | |
1055 VMThread::execute(&op); | |
1056 } | |
1057 } |