src/share/vm/utilities/vmError.cpp

Tue, 08 Nov 2011 00:41:28 -0500

author
tonyp
date
Tue, 08 Nov 2011 00:41:28 -0500
changeset 3269
53074c2c4600
parent 3156
f08d439fab8c
child 3430
d7e3846464d0
permissions
-rw-r--r--

7099849: G1: include heap region information in hs_err files
Reviewed-by: johnc, brutisso, poonam

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

mercurial