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