1 /* 2 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include <fcntl.h> 26 #include "precompiled.hpp" 27 #include "code/codeCache.hpp" 28 #include "compiler/compileBroker.hpp" 29 #include "compiler/disassembler.hpp" 30 #include "gc/shared/collectedHeap.hpp" 31 #include "logging/logConfiguration.hpp" 32 #include "prims/whitebox.hpp" 33 #include "runtime/arguments.hpp" 34 #include "runtime/atomic.hpp" 35 #include "runtime/frame.inline.hpp" 36 #include "runtime/init.hpp" 37 #include "runtime/os.hpp" 38 #include "runtime/thread.inline.hpp" 39 #include "runtime/vmThread.hpp" 40 #include "runtime/vm_operations.hpp" 41 #include "services/memTracker.hpp" 42 #include "trace/traceMacros.hpp" 43 #include "utilities/debug.hpp" 44 #include "utilities/decoder.hpp" 45 #include "utilities/defaultStream.hpp" 46 #include "utilities/errorReporter.hpp" 47 #include "utilities/events.hpp" 48 #include "utilities/vmError.hpp" 49 50 // List of environment variables that should be reported in error log file. 51 const char *env_list[] = { 52 // All platforms 53 "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH", 54 "JAVA_COMPILER", "PATH", "USERNAME", 55 56 // Env variables that are defined on Solaris/Linux/BSD 57 "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY", 58 "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE", 59 60 // defined on Linux 61 "LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM", 62 63 // defined on Darwin 64 "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH", 65 "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH", 66 "DYLD_INSERT_LIBRARIES", 67 68 // defined on Windows 69 "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR", 70 71 (const char *)0 72 }; 73 74 // A simple parser for -XX:OnError, usage: 75 // ptr = OnError; 76 // while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr) != NULL) 77 // ... ... 78 static char* next_OnError_command(char* buf, int buflen, const char** ptr) { 79 if (ptr == NULL || *ptr == NULL) return NULL; 80 81 const char* cmd = *ptr; 82 83 // skip leading blanks or ';' 84 while (*cmd == ' ' || *cmd == ';') cmd++; 85 86 if (*cmd == '\0') return NULL; 87 88 const char * cmdend = cmd; 89 while (*cmdend != '\0' && *cmdend != ';') cmdend++; 90 91 Arguments::copy_expand_pid(cmd, cmdend - cmd, buf, buflen); 92 93 *ptr = (*cmdend == '\0' ? cmdend : cmdend + 1); 94 return buf; 95 } 96 97 static void print_bug_submit_message(outputStream *out, Thread *thread) { 98 if (out == NULL) return; 99 out->print_raw_cr("# If you would like to submit a bug report, please visit:"); 100 out->print_raw ("# "); 101 out->print_raw_cr(Arguments::java_vendor_url_bug()); 102 // If the crash is in native code, encourage user to submit a bug to the 103 // provider of that code. 104 if (thread && thread->is_Java_thread() && 105 !thread->is_hidden_from_external_view()) { 106 JavaThread* jt = (JavaThread*)thread; 107 if (jt->thread_state() == _thread_in_native) { 108 out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug."); 109 } 110 } 111 out->print_raw_cr("#"); 112 } 113 114 bool VMError::coredump_status; 115 char VMError::coredump_message[O_BUFLEN]; 116 117 void VMError::record_coredump_status(const char* message, bool status) { 118 coredump_status = status; 119 strncpy(coredump_message, message, sizeof(coredump_message)); 120 coredump_message[sizeof(coredump_message)-1] = 0; 121 } 122 123 // Return a string to describe the error 124 char* VMError::error_string(char* buf, int buflen) { 125 char signame_buf[64]; 126 const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf)); 127 128 if (signame) { 129 jio_snprintf(buf, buflen, 130 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, 131 signame, _id, _pc, 132 os::current_process_id(), os::current_thread_id()); 133 } else if (_filename != NULL && _lineno > 0) { 134 // skip directory names 135 char separator = os::file_separator()[0]; 136 const char *p = strrchr(_filename, separator); 137 int n = jio_snprintf(buf, buflen, 138 "Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT, 139 p ? p + 1 : _filename, _lineno, 140 os::current_process_id(), os::current_thread_id()); 141 if (n >= 0 && n < buflen && _message) { 142 if (strlen(_detail_msg) > 0) { 143 jio_snprintf(buf + n, buflen - n, "%s%s: %s", 144 os::line_separator(), _message, _detail_msg); 145 } else { 146 jio_snprintf(buf + n, buflen - n, "%sError: %s", 147 os::line_separator(), _message); 148 } 149 } 150 } else { 151 jio_snprintf(buf, buflen, 152 "Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT, 153 _id, os::current_process_id(), os::current_thread_id()); 154 } 155 156 return buf; 157 } 158 159 void VMError::print_stack_trace(outputStream* st, JavaThread* jt, 160 char* buf, int buflen, bool verbose) { 161 #ifdef ZERO 162 if (jt->zero_stack()->sp() && jt->top_zero_frame()) { 163 // StackFrameStream uses the frame anchor, which may not have 164 // been set up. This can be done at any time in Zero, however, 165 // so if it hasn't been set up then we just set it up now and 166 // clear it again when we're done. 167 bool has_last_Java_frame = jt->has_last_Java_frame(); 168 if (!has_last_Java_frame) 169 jt->set_last_Java_frame(); 170 st->print("Java frames:"); 171 172 // If the top frame is a Shark frame and the frame anchor isn't 173 // set up then it's possible that the information in the frame 174 // is garbage: it could be from a previous decache, or it could 175 // simply have never been written. So we print a warning... 176 StackFrameStream sfs(jt); 177 if (!has_last_Java_frame && !sfs.is_done()) { 178 if (sfs.current()->zeroframe()->is_shark_frame()) { 179 st->print(" (TOP FRAME MAY BE JUNK)"); 180 } 181 } 182 st->cr(); 183 184 // Print the frames 185 for(int i = 0; !sfs.is_done(); sfs.next(), i++) { 186 sfs.current()->zero_print_on_error(i, st, buf, buflen); 187 st->cr(); 188 } 189 190 // Reset the frame anchor if necessary 191 if (!has_last_Java_frame) 192 jt->reset_last_Java_frame(); 193 } 194 #else 195 if (jt->has_last_Java_frame()) { 196 st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)"); 197 for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) { 198 sfs.current()->print_on_error(st, buf, buflen, verbose); 199 st->cr(); 200 } 201 } 202 #endif // ZERO 203 } 204 205 static void print_oom_reasons(outputStream* st) { 206 st->print_cr("# Possible reasons:"); 207 st->print_cr("# The system is out of physical RAM or swap space"); 208 if (UseCompressedOops) { 209 st->print_cr("# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap"); 210 } 211 if (LogBytesPerWord == 2) { 212 st->print_cr("# In 32 bit mode, the process size limit was hit"); 213 } 214 st->print_cr("# Possible solutions:"); 215 st->print_cr("# Reduce memory load on the system"); 216 st->print_cr("# Increase physical memory or swap space"); 217 st->print_cr("# Check if swap backing store is full"); 218 if (LogBytesPerWord == 2) { 219 st->print_cr("# Use 64 bit Java on a 64 bit OS"); 220 } 221 st->print_cr("# Decrease Java heap size (-Xmx/-Xms)"); 222 st->print_cr("# Decrease number of Java threads"); 223 st->print_cr("# Decrease Java thread stack sizes (-Xss)"); 224 st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize="); 225 if (UseCompressedOops) { 226 switch (Universe::narrow_oop_mode()) { 227 case Universe::UnscaledNarrowOop: 228 st->print_cr("# JVM is running with Unscaled Compressed Oops mode in which the Java heap is"); 229 st->print_cr("# placed in the first 4GB address space. The Java Heap base address is the"); 230 st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress"); 231 st->print_cr("# to set the Java Heap base and to place the Java Heap above 4GB virtual address."); 232 break; 233 case Universe::ZeroBasedNarrowOop: 234 st->print_cr("# JVM is running with Zero Based Compressed Oops mode in which the Java heap is"); 235 st->print_cr("# placed in the first 32GB address space. The Java Heap base address is the"); 236 st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress"); 237 st->print_cr("# to set the Java Heap base and to place the Java Heap above 32GB virtual address."); 238 break; 239 } 240 } 241 st->print_cr("# This output file may be truncated or incomplete."); 242 } 243 244 static const char* gc_mode() { 245 if (UseG1GC) return "g1 gc"; 246 if (UseParallelGC) return "parallel gc"; 247 if (UseConcMarkSweepGC) return "concurrent mark sweep gc"; 248 if (UseSerialGC) return "serial gc"; 249 return "ERROR in GC mode"; 250 } 251 252 static void report_vm_version(outputStream* st, char* buf, int buflen) { 253 // VM version 254 st->print_cr("#"); 255 JDK_Version::current().to_string(buf, buflen); 256 const char* runtime_name = JDK_Version::runtime_name() != NULL ? 257 JDK_Version::runtime_name() : ""; 258 const char* runtime_version = JDK_Version::runtime_version() != NULL ? 259 JDK_Version::runtime_version() : ""; 260 const char* jdk_debug_level = Abstract_VM_Version::printable_jdk_debug_level() != NULL ? 261 Abstract_VM_Version::printable_jdk_debug_level() : ""; 262 263 st->print_cr("# JRE version: %s (%s) (%sbuild %s)", runtime_name, buf, 264 jdk_debug_level, runtime_version); 265 266 // This is the long version with some default settings added 267 st->print_cr("# Java VM: %s (%s%s, %s%s%s%s%s, %s, %s)", 268 Abstract_VM_Version::vm_name(), 269 jdk_debug_level, 270 Abstract_VM_Version::vm_release(), 271 Abstract_VM_Version::vm_info_string(), 272 TieredCompilation ? ", tiered" : "", 273 #if INCLUDE_JVMCI 274 EnableJVMCI ? ", jvmci" : "", 275 UseJVMCICompiler ? ", jvmci compiler" : "", 276 #else 277 "", "", 278 #endif 279 UseCompressedOops ? ", compressed oops" : "", 280 gc_mode(), 281 Abstract_VM_Version::vm_platform_string() 282 ); 283 } 284 285 // This is the main function to report a fatal error. Only one thread can 286 // call this function, so we don't need to worry about MT-safety. But it's 287 // possible that the error handler itself may crash or die on an internal 288 // error, for example, when the stack/heap is badly damaged. We must be 289 // able to handle recursive errors that happen inside error handler. 290 // 291 // Error reporting is done in several steps. If a crash or internal error 292 // occurred when reporting an error, the nested signal/exception handler 293 // can skip steps that are already (or partially) done. Error reporting will 294 // continue from the next step. This allows us to retrieve and print 295 // information that may be unsafe to get after a fatal error. If it happens, 296 // you may find nested report_and_die() frames when you look at the stack 297 // in a debugger. 298 // 299 // In general, a hang in error handler is much worse than a crash or internal 300 // error, as it's harder to recover from a hang. Deadlock can happen if we 301 // try to grab a lock that is already owned by current thread, or if the 302 // owner is blocked forever (e.g. in os::infinite_sleep()). If possible, the 303 // error handler and all the functions it called should avoid grabbing any 304 // lock. An important thing to notice is that memory allocation needs a lock. 305 // 306 // We should avoid using large stack allocated buffers. Many errors happen 307 // when stack space is already low. Making things even worse is that there 308 // could be nested report_and_die() calls on stack (see above). Only one 309 // thread can report error, so large buffers are statically allocated in data 310 // segment. 311 312 int VMError::_current_step; 313 const char* VMError::_current_step_info; 314 315 void VMError::report(outputStream* st, bool _verbose) { 316 317 # define BEGIN if (_current_step == 0) { _current_step = __LINE__; 318 # define STEP(s) } if (_current_step < __LINE__) { _current_step = __LINE__; _current_step_info = s; 319 # define END } 320 321 // don't allocate large buffer on stack 322 static char buf[O_BUFLEN]; 323 324 BEGIN 325 326 STEP("printing fatal error message") 327 328 st->print_cr("#"); 329 if (should_report_bug(_id)) { 330 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); 331 } else { 332 st->print_cr("# There is insufficient memory for the Java " 333 "Runtime Environment to continue."); 334 } 335 336 #ifndef PRODUCT 337 // Error handler self tests 338 339 // test secondary error handling. Test it twice, to test that resetting 340 // error handler after a secondary crash works. 341 STEP("test secondary crash 1") 342 if (_verbose && TestCrashInErrorHandler != 0) { 343 st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...", 344 TestCrashInErrorHandler); 345 controlled_crash(TestCrashInErrorHandler); 346 } 347 348 STEP("test secondary crash 2") 349 if (_verbose && TestCrashInErrorHandler != 0) { 350 st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...", 351 TestCrashInErrorHandler); 352 controlled_crash(TestCrashInErrorHandler); 353 } 354 355 STEP("test safefetch in error handler") 356 // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice 357 // to test that resetting the signal handler works correctly. 358 if (_verbose && TestSafeFetchInErrorHandler) { 359 st->print_cr("Will test SafeFetch..."); 360 if (CanUseSafeFetch32()) { 361 int* const invalid_pointer = (int*) get_segfault_address(); 362 const int x = 0x76543210; 363 int i1 = SafeFetch32(invalid_pointer, x); 364 int i2 = SafeFetch32(invalid_pointer, x); 365 if (i1 == x && i2 == x) { 366 st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern 367 } else { 368 st->print_cr("??"); 369 } 370 } else { 371 st->print_cr("not possible; skipped."); 372 } 373 } 374 #endif // PRODUCT 375 376 STEP("printing type of error") 377 378 switch(_id) { 379 case OOM_MALLOC_ERROR: 380 case OOM_MMAP_ERROR: 381 if (_size) { 382 st->print("# Native memory allocation "); 383 st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " : 384 "(mmap) failed to map "); 385 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size); 386 st->print("%s", buf); 387 st->print(" bytes"); 388 if (strlen(_detail_msg) > 0) { 389 st->print(" for "); 390 st->print("%s", _detail_msg); 391 } 392 st->cr(); 393 } else { 394 if (strlen(_detail_msg) > 0) { 395 st->print("# "); 396 st->print_cr("%s", _detail_msg); 397 } 398 } 399 // In error file give some solutions 400 if (_verbose) { 401 print_oom_reasons(st); 402 } else { 403 return; // that's enough for the screen 404 } 405 break; 406 case INTERNAL_ERROR: 407 default: 408 break; 409 } 410 411 STEP("printing exception/signal name") 412 413 st->print_cr("#"); 414 st->print("# "); 415 // Is it an OS exception/signal? 416 if (os::exception_name(_id, buf, sizeof(buf))) { 417 st->print("%s", buf); 418 st->print(" (0x%x)", _id); // signal number 419 st->print(" at pc=" PTR_FORMAT, p2i(_pc)); 420 } else { 421 if (should_report_bug(_id)) { 422 st->print("Internal Error"); 423 } else { 424 st->print("Out of Memory Error"); 425 } 426 if (_filename != NULL && _lineno > 0) { 427 #ifdef PRODUCT 428 // In product mode chop off pathname? 429 char separator = os::file_separator()[0]; 430 const char *p = strrchr(_filename, separator); 431 const char *file = p ? p+1 : _filename; 432 #else 433 const char *file = _filename; 434 #endif 435 st->print(" (%s:%d)", file, _lineno); 436 } else { 437 st->print(" (0x%x)", _id); 438 } 439 } 440 441 STEP("printing current thread and pid") 442 443 // process id, thread id 444 st->print(", pid=%d", os::current_process_id()); 445 st->print(", tid=" UINTX_FORMAT, os::current_thread_id()); 446 st->cr(); 447 448 STEP("printing error message") 449 450 if (should_report_bug(_id)) { // already printed the message. 451 // error message 452 if (strlen(_detail_msg) > 0) { 453 st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); 454 } else if (_message) { 455 st->print_cr("# Error: %s", _message); 456 } 457 } 458 459 STEP("printing Java version string") 460 461 report_vm_version(st, buf, sizeof(buf)); 462 463 STEP("printing problematic frame") 464 465 // Print current frame if we have a context (i.e. it's a crash) 466 if (_context) { 467 st->print_cr("# Problematic frame:"); 468 st->print("# "); 469 frame fr = os::fetch_frame_from_context(_context); 470 fr.print_on_error(st, buf, sizeof(buf)); 471 st->cr(); 472 st->print_cr("#"); 473 } 474 475 STEP("printing core file information") 476 st->print("# "); 477 if (CreateCoredumpOnCrash) { 478 if (coredump_status) { 479 st->print("Core dump will be written. Default location: %s", coredump_message); 480 } else { 481 st->print("No core dump will be written. %s", coredump_message); 482 } 483 } else { 484 st->print("CreateCoredumpOnCrash turned off, no core file dumped"); 485 } 486 st->cr(); 487 st->print_cr("#"); 488 489 STEP("printing bug submit message") 490 491 if (should_report_bug(_id) && _verbose) { 492 print_bug_submit_message(st, _thread); 493 } 494 495 STEP("printing summary") 496 497 if (_verbose) { 498 st->cr(); 499 st->print_cr("--------------- S U M M A R Y ------------"); 500 st->cr(); 501 } 502 503 STEP("printing VM option summary") 504 505 if (_verbose) { 506 // VM options 507 Arguments::print_summary_on(st); 508 st->cr(); 509 } 510 511 STEP("printing summary machine and OS info") 512 513 if (_verbose) { 514 os::print_summary_info(st, buf, sizeof(buf)); 515 } 516 517 518 STEP("printing date and time") 519 520 if (_verbose) { 521 os::print_date_and_time(st, buf, sizeof(buf)); 522 } 523 524 STEP("printing thread") 525 526 if (_verbose) { 527 st->cr(); 528 st->print_cr("--------------- T H R E A D ---------------"); 529 st->cr(); 530 } 531 532 STEP("printing current thread") 533 534 // current thread 535 if (_verbose) { 536 if (_thread) { 537 st->print("Current thread (" PTR_FORMAT "): ", p2i(_thread)); 538 _thread->print_on_error(st, buf, sizeof(buf)); 539 st->cr(); 540 } else { 541 st->print_cr("Current thread is native thread"); 542 } 543 st->cr(); 544 } 545 546 STEP("printing current compile task") 547 548 if (_verbose && _thread && _thread->is_Compiler_thread()) { 549 CompilerThread* t = (CompilerThread*)_thread; 550 if (t->task()) { 551 st->cr(); 552 st->print_cr("Current CompileTask:"); 553 t->task()->print_line_on_error(st, buf, sizeof(buf)); 554 st->cr(); 555 } 556 } 557 558 559 STEP("printing stack bounds") 560 561 if (_verbose) { 562 st->print("Stack: "); 563 564 address stack_top; 565 size_t stack_size; 566 567 if (_thread) { 568 stack_top = _thread->stack_base(); 569 stack_size = _thread->stack_size(); 570 } else { 571 stack_top = os::current_stack_base(); 572 stack_size = os::current_stack_size(); 573 } 574 575 address stack_bottom = stack_top - stack_size; 576 st->print("[" PTR_FORMAT "," PTR_FORMAT "]", p2i(stack_bottom), p2i(stack_top)); 577 578 frame fr = _context ? os::fetch_frame_from_context(_context) 579 : os::current_frame(); 580 581 if (fr.sp()) { 582 st->print(", sp=" PTR_FORMAT, p2i(fr.sp())); 583 size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024); 584 st->print(", free space=" SIZE_FORMAT "k", free_stack_size); 585 } 586 587 st->cr(); 588 } 589 590 STEP("printing native stack") 591 592 if (_verbose) { 593 if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) { 594 // We have printed the native stack in platform-specific code 595 // Windows/x64 needs special handling. 596 } else { 597 frame fr = _context ? os::fetch_frame_from_context(_context) 598 : os::current_frame(); 599 600 print_native_stack(st, fr, _thread, buf, sizeof(buf)); 601 } 602 } 603 604 STEP("printing Java stack") 605 606 if (_verbose && _thread && _thread->is_Java_thread()) { 607 print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf)); 608 } 609 610 STEP("printing target Java thread stack") 611 612 // printing Java thread stack trace if it is involved in GC crash 613 if (_verbose && _thread && (_thread->is_Named_thread())) { 614 JavaThread* jt = ((NamedThread *)_thread)->processed_thread(); 615 if (jt != NULL) { 616 st->print_cr("JavaThread " PTR_FORMAT " (nid = %d) was being processed", p2i(jt), jt->osthread()->thread_id()); 617 print_stack_trace(st, jt, buf, sizeof(buf), true); 618 } 619 } 620 621 STEP("printing siginfo") 622 623 // signal no, signal code, address that caused the fault 624 if (_verbose && _siginfo) { 625 st->cr(); 626 os::print_siginfo(st, _siginfo); 627 st->cr(); 628 } 629 630 STEP("CDS archive access warning") 631 632 // Print an explicit hint if we crashed on access to the CDS archive. 633 if (_verbose && _siginfo) { 634 check_failing_cds_access(st, _siginfo); 635 st->cr(); 636 } 637 638 STEP("printing register info") 639 640 // decode register contents if possible 641 if (_verbose && _context && Universe::is_fully_initialized()) { 642 os::print_register_info(st, _context); 643 st->cr(); 644 } 645 646 STEP("printing registers, top of stack, instructions near pc") 647 648 // registers, top of stack, instructions near pc 649 if (_verbose && _context) { 650 os::print_context(st, _context); 651 st->cr(); 652 } 653 654 STEP("printing code blob if possible") 655 656 if (_verbose && _context) { 657 CodeBlob* cb = CodeCache::find_blob(_pc); 658 if (cb != NULL) { 659 if (Interpreter::contains(_pc)) { 660 // The interpreter CodeBlob is very large so try to print the codelet instead. 661 InterpreterCodelet* codelet = Interpreter::codelet_containing(_pc); 662 if (codelet != NULL) { 663 codelet->print_on(st); 664 Disassembler::decode(codelet->code_begin(), codelet->code_end(), st); 665 } 666 } else { 667 StubCodeDesc* desc = StubCodeDesc::desc_for(_pc); 668 if (desc != NULL) { 669 desc->print_on(st); 670 Disassembler::decode(desc->begin(), desc->end(), st); 671 } else { 672 Disassembler::decode(cb, st); 673 st->cr(); 674 } 675 } 676 } 677 } 678 679 STEP("printing VM operation") 680 681 if (_verbose && _thread && _thread->is_VM_thread()) { 682 VMThread* t = (VMThread*)_thread; 683 VM_Operation* op = t->vm_operation(); 684 if (op) { 685 op->print_on_error(st); 686 st->cr(); 687 st->cr(); 688 } 689 } 690 691 STEP("printing process") 692 693 if (_verbose) { 694 st->cr(); 695 st->print_cr("--------------- P R O C E S S ---------------"); 696 st->cr(); 697 } 698 699 STEP("printing all threads") 700 701 // all threads 702 if (_verbose && _thread) { 703 Threads::print_on_error(st, _thread, buf, sizeof(buf)); 704 st->cr(); 705 } 706 707 STEP("printing VM state") 708 709 if (_verbose) { 710 // Safepoint state 711 st->print("VM state:"); 712 713 if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing"); 714 else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint"); 715 else st->print("not at safepoint"); 716 717 // Also see if error occurred during initialization or shutdown 718 if (!Universe::is_fully_initialized()) { 719 st->print(" (not fully initialized)"); 720 } else if (VM_Exit::vm_exited()) { 721 st->print(" (shutting down)"); 722 } else { 723 st->print(" (normal execution)"); 724 } 725 st->cr(); 726 st->cr(); 727 } 728 729 STEP("printing owned locks on error") 730 731 // mutexes/monitors that currently have an owner 732 if (_verbose) { 733 print_owned_locks_on_error(st); 734 st->cr(); 735 } 736 737 STEP("printing number of OutOfMemoryError and StackOverflow exceptions") 738 739 if (_verbose && Exceptions::has_exception_counts()) { 740 st->print_cr("OutOfMemory and StackOverflow Exception counts:"); 741 Exceptions::print_exception_counts_on_error(st); 742 st->cr(); 743 } 744 745 STEP("printing compressed oops mode") 746 747 if (_verbose && UseCompressedOops) { 748 Universe::print_compressed_oops_mode(st); 749 if (UseCompressedClassPointers) { 750 Metaspace::print_compressed_class_space(st); 751 } 752 st->cr(); 753 } 754 755 STEP("printing heap information") 756 757 if (_verbose && Universe::is_fully_initialized()) { 758 Universe::heap()->print_on_error(st); 759 st->cr(); 760 st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page())); 761 st->cr(); 762 } 763 764 STEP("printing code cache information") 765 766 if (_verbose && Universe::is_fully_initialized()) { 767 // print code cache information before vm abort 768 CodeCache::print_summary(st); 769 st->cr(); 770 } 771 772 STEP("printing ring buffers") 773 774 if (_verbose) { 775 Events::print_all(st); 776 st->cr(); 777 } 778 779 STEP("printing dynamic libraries") 780 781 if (_verbose) { 782 // dynamic libraries, or memory map 783 os::print_dll_info(st); 784 st->cr(); 785 } 786 787 STEP("printing VM options") 788 789 if (_verbose) { 790 // VM options 791 Arguments::print_on(st); 792 st->cr(); 793 } 794 795 STEP("printing warning if internal testing API used") 796 797 if (WhiteBox::used()) { 798 st->print_cr("Unsupported internal testing APIs have been used."); 799 st->cr(); 800 } 801 802 STEP("printing log configuration") 803 if (_verbose){ 804 st->print_cr("Logging:"); 805 LogConfiguration::describe_current_configuration(st); 806 st->cr(); 807 } 808 809 STEP("printing all environment variables") 810 811 if (_verbose) { 812 os::print_environment_variables(st, env_list); 813 st->cr(); 814 } 815 816 STEP("printing signal handlers") 817 818 if (_verbose) { 819 os::print_signal_handlers(st, buf, sizeof(buf)); 820 st->cr(); 821 } 822 823 STEP("Native Memory Tracking") 824 if (_verbose) { 825 MemTracker::error_report(st); 826 } 827 828 STEP("printing system") 829 830 if (_verbose) { 831 st->cr(); 832 st->print_cr("--------------- S Y S T E M ---------------"); 833 st->cr(); 834 } 835 836 STEP("printing OS information") 837 838 if (_verbose) { 839 os::print_os_info(st); 840 st->cr(); 841 } 842 843 STEP("printing CPU info") 844 if (_verbose) { 845 os::print_cpu_info(st, buf, sizeof(buf)); 846 st->cr(); 847 } 848 849 STEP("printing memory info") 850 851 if (_verbose) { 852 os::print_memory_info(st); 853 st->cr(); 854 } 855 856 STEP("printing internal vm info") 857 858 if (_verbose) { 859 st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); 860 st->cr(); 861 } 862 863 // print a defined marker to show that error handling finished correctly. 864 STEP("printing end marker") 865 866 if (_verbose) { 867 st->print_cr("END."); 868 } 869 870 END 871 872 # undef BEGIN 873 # undef STEP 874 # undef END 875 } 876 877 // Report for the vm_info_cmd. This prints out the information above omitting 878 // crash and thread specific information. If output is added above, it should be added 879 // here also, if it is safe to call during a running process. 880 void VMError::print_vm_info(outputStream* st) { 881 882 char buf[O_BUFLEN]; 883 report_vm_version(st, buf, sizeof(buf)); 884 885 // STEP("printing summary") 886 887 st->cr(); 888 st->print_cr("--------------- S U M M A R Y ------------"); 889 st->cr(); 890 891 // STEP("printing VM option summary") 892 893 // VM options 894 Arguments::print_summary_on(st); 895 st->cr(); 896 897 // STEP("printing summary machine and OS info") 898 899 os::print_summary_info(st, buf, sizeof(buf)); 900 901 // STEP("printing date and time") 902 903 os::print_date_and_time(st, buf, sizeof(buf)); 904 905 // Skip: STEP("printing thread") 906 907 // STEP("printing process") 908 909 st->cr(); 910 st->print_cr("--------------- P R O C E S S ---------------"); 911 st->cr(); 912 913 // STEP("printing number of OutOfMemoryError and StackOverflow exceptions") 914 915 if (Exceptions::has_exception_counts()) { 916 st->print_cr("OutOfMemory and StackOverflow Exception counts:"); 917 Exceptions::print_exception_counts_on_error(st); 918 st->cr(); 919 } 920 921 // STEP("printing compressed oops mode") 922 923 if (UseCompressedOops) { 924 Universe::print_compressed_oops_mode(st); 925 if (UseCompressedClassPointers) { 926 Metaspace::print_compressed_class_space(st); 927 } 928 st->cr(); 929 } 930 931 // STEP("printing heap information") 932 933 if (Universe::is_fully_initialized()) { 934 MutexLocker hl(Heap_lock); 935 Universe::heap()->print_on_error(st); 936 st->cr(); 937 st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page())); 938 st->cr(); 939 } 940 941 // STEP("printing code cache information") 942 943 if (Universe::is_fully_initialized()) { 944 // print code cache information before vm abort 945 CodeCache::print_summary(st); 946 st->cr(); 947 } 948 949 // STEP("printing ring buffers") 950 951 Events::print_all(st); 952 st->cr(); 953 954 // STEP("printing dynamic libraries") 955 956 // dynamic libraries, or memory map 957 os::print_dll_info(st); 958 st->cr(); 959 960 // STEP("printing VM options") 961 962 // VM options 963 Arguments::print_on(st); 964 st->cr(); 965 966 // STEP("printing warning if internal testing API used") 967 968 if (WhiteBox::used()) { 969 st->print_cr("Unsupported internal testing APIs have been used."); 970 st->cr(); 971 } 972 973 // STEP("printing log configuration") 974 st->print_cr("Logging:"); 975 LogConfiguration::describe(st); 976 st->cr(); 977 978 // STEP("printing all environment variables") 979 980 os::print_environment_variables(st, env_list); 981 st->cr(); 982 983 // STEP("printing signal handlers") 984 985 os::print_signal_handlers(st, buf, sizeof(buf)); 986 st->cr(); 987 988 // STEP("Native Memory Tracking") 989 990 MemTracker::error_report(st); 991 992 // STEP("printing system") 993 994 st->cr(); 995 st->print_cr("--------------- S Y S T E M ---------------"); 996 st->cr(); 997 998 // STEP("printing OS information") 999 1000 os::print_os_info(st); 1001 st->cr(); 1002 1003 // STEP("printing CPU info") 1004 1005 os::print_cpu_info(st, buf, sizeof(buf)); 1006 st->cr(); 1007 1008 // STEP("printing memory info") 1009 1010 os::print_memory_info(st); 1011 st->cr(); 1012 1013 // STEP("printing internal vm info") 1014 1015 st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string()); 1016 st->cr(); 1017 1018 // print a defined marker to show that error handling finished correctly. 1019 // STEP("printing end marker") 1020 1021 st->print_cr("END."); 1022 } 1023 1024 volatile intptr_t VMError::first_error_tid = -1; 1025 1026 // An error could happen before tty is initialized or after it has been 1027 // destroyed. 1028 // Please note: to prevent large stack allocations, the log- and 1029 // output-stream use a global scratch buffer for format printing. 1030 // (see VmError::report_and_die(). Access to those streams is synchronized 1031 // in VmError::report_and_die() - there is only one reporting thread at 1032 // any given time. 1033 fdStream VMError::out(defaultStream::output_fd()); 1034 fdStream VMError::log; // error log used by VMError::report_and_die() 1035 1036 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */ 1037 static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) { 1038 int fd = -1; 1039 if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) { 1040 // the O_EXCL flag will cause the open to fail if the file exists 1041 fd = open(buf, O_RDWR | O_CREAT | O_EXCL, 0666); 1042 } 1043 return fd; 1044 } 1045 1046 /** 1047 * Construct file name for a log file and return it's file descriptor. 1048 * Name and location depends on pattern, default_pattern params and access 1049 * permissions. 1050 */ 1051 static int prepare_log_file(const char* pattern, const char* default_pattern, char* buf, size_t buflen) { 1052 int fd = -1; 1053 1054 // If possible, use specified pattern to construct log file name 1055 if (pattern != NULL) { 1056 fd = expand_and_open(pattern, buf, buflen, 0); 1057 } 1058 1059 // Either user didn't specify, or the user's location failed, 1060 // so use the default name in the current directory 1061 if (fd == -1) { 1062 const char* cwd = os::get_current_directory(buf, buflen); 1063 if (cwd != NULL) { 1064 size_t pos = strlen(cwd); 1065 int fsep_len = jio_snprintf(&buf[pos], buflen-pos, "%s", os::file_separator()); 1066 pos += fsep_len; 1067 if (fsep_len > 0) { 1068 fd = expand_and_open(default_pattern, buf, buflen, pos); 1069 } 1070 } 1071 } 1072 1073 // try temp directory if it exists. 1074 if (fd == -1) { 1075 const char* tmpdir = os::get_temp_directory(); 1076 if (tmpdir != NULL && strlen(tmpdir) > 0) { 1077 int pos = jio_snprintf(buf, buflen, "%s%s", tmpdir, os::file_separator()); 1078 if (pos > 0) { 1079 fd = expand_and_open(default_pattern, buf, buflen, pos); 1080 } 1081 } 1082 } 1083 1084 return fd; 1085 } 1086 1087 int VMError::_id; 1088 const char* VMError::_message; 1089 char VMError::_detail_msg[1024]; 1090 Thread* VMError::_thread; 1091 address VMError::_pc; 1092 void* VMError::_siginfo; 1093 void* VMError::_context; 1094 const char* VMError::_filename; 1095 int VMError::_lineno; 1096 size_t VMError::_size; 1097 1098 void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, 1099 void* context, const char* detail_fmt, ...) 1100 { 1101 va_list detail_args; 1102 va_start(detail_args, detail_fmt); 1103 report_and_die(sig, NULL, detail_fmt, detail_args, thread, pc, siginfo, context, NULL, 0, 0); 1104 va_end(detail_args); 1105 } 1106 1107 void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context) 1108 { 1109 report_and_die(thread, sig, pc, siginfo, context, "%s", ""); 1110 } 1111 1112 void VMError::report_and_die(const char* message, const char* detail_fmt, ...) 1113 { 1114 va_list detail_args; 1115 va_start(detail_args, detail_fmt); 1116 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, NULL, NULL, NULL, NULL, NULL, 0, 0); 1117 va_end(detail_args); 1118 } 1119 1120 void VMError::report_and_die(const char* message) 1121 { 1122 report_and_die(message, "%s", ""); 1123 } 1124 1125 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, const char* message, 1126 const char* detail_fmt, va_list detail_args) 1127 { 1128 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, 0); 1129 } 1130 1131 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size, 1132 VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) { 1133 report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size); 1134 } 1135 1136 void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args, 1137 Thread* thread, address pc, void* siginfo, void* context, const char* filename, 1138 int lineno, size_t size) 1139 { 1140 // Don't allocate large buffer on stack 1141 static char buffer[O_BUFLEN]; 1142 out.set_scratch_buffer(buffer, sizeof(buffer)); 1143 log.set_scratch_buffer(buffer, sizeof(buffer)); 1144 1145 // How many errors occurred in error handler when reporting first_error. 1146 static int recursive_error_count; 1147 1148 // We will first print a brief message to standard out (verbose = false), 1149 // then save detailed information in log file (verbose = true). 1150 static bool out_done = false; // done printing to standard out 1151 static bool log_done = false; // done saving error log 1152 static bool transmit_report_done = false; // done error reporting 1153 1154 if (SuppressFatalErrorMessage) { 1155 os::abort(CreateCoredumpOnCrash); 1156 } 1157 intptr_t mytid = os::current_thread_id(); 1158 if (first_error_tid == -1 && 1159 Atomic::cmpxchg_ptr(mytid, &first_error_tid, -1) == -1) { 1160 1161 // Initialize time stamps to use the same base. 1162 out.time_stamp().update_to(1); 1163 log.time_stamp().update_to(1); 1164 1165 _id = id; 1166 _message = message; 1167 _thread = thread; 1168 _pc = pc; 1169 _siginfo = siginfo; 1170 _context = context; 1171 _filename = filename; 1172 _lineno = lineno; 1173 _size = size; 1174 jio_vsnprintf(_detail_msg, sizeof(_detail_msg), detail_fmt, detail_args); 1175 1176 // first time 1177 set_error_reported(); 1178 1179 if (ShowMessageBoxOnError || PauseAtExit) { 1180 show_message_box(buffer, sizeof(buffer)); 1181 1182 // User has asked JVM to abort. Reset ShowMessageBoxOnError so the 1183 // WatcherThread can kill JVM if the error handler hangs. 1184 ShowMessageBoxOnError = false; 1185 } 1186 1187 os::check_dump_limit(buffer, sizeof(buffer)); 1188 1189 // reset signal handlers or exception filter; make sure recursive crashes 1190 // are handled properly. 1191 reset_signal_handlers(); 1192 1193 TRACE_VM_ERROR(); 1194 1195 } else { 1196 // If UseOsErrorReporting we call this for each level of the call stack 1197 // while searching for the exception handler. Only the first level needs 1198 // to be reported. 1199 if (UseOSErrorReporting && log_done) return; 1200 1201 // This is not the first error, see if it happened in a different thread 1202 // or in the same thread during error reporting. 1203 if (first_error_tid != mytid) { 1204 char msgbuf[64]; 1205 jio_snprintf(msgbuf, sizeof(msgbuf), 1206 "[thread " INTX_FORMAT " also had an error]", 1207 mytid); 1208 out.print_raw_cr(msgbuf); 1209 1210 // error reporting is not MT-safe, block current thread 1211 os::infinite_sleep(); 1212 1213 } else { 1214 if (recursive_error_count++ > 30) { 1215 out.print_raw_cr("[Too many errors, abort]"); 1216 os::die(); 1217 } 1218 1219 jio_snprintf(buffer, sizeof(buffer), 1220 "[error occurred during error reporting (%s), id 0x%x]", 1221 _current_step_info, _id); 1222 if (log.is_open()) { 1223 log.cr(); 1224 log.print_raw_cr(buffer); 1225 log.cr(); 1226 } else { 1227 out.cr(); 1228 out.print_raw_cr(buffer); 1229 out.cr(); 1230 } 1231 } 1232 } 1233 1234 // print to screen 1235 if (!out_done) { 1236 report(&out, false); 1237 1238 out_done = true; 1239 1240 _current_step = 0; 1241 _current_step_info = ""; 1242 } 1243 1244 // print to error log file 1245 if (!log_done) { 1246 // see if log file is already open 1247 if (!log.is_open()) { 1248 // open log file 1249 int fd = prepare_log_file(ErrorFile, "hs_err_pid%p.log", buffer, sizeof(buffer)); 1250 if (fd != -1) { 1251 out.print_raw("# An error report file with more information is saved as:\n# "); 1252 out.print_raw_cr(buffer); 1253 1254 log.set_fd(fd); 1255 } else { 1256 out.print_raw_cr("# Can not save log file, dump to screen.."); 1257 log.set_fd(defaultStream::output_fd()); 1258 /* Error reporting currently needs dumpfile. 1259 * Maybe implement direct streaming in the future.*/ 1260 transmit_report_done = true; 1261 } 1262 } 1263 1264 report(&log, true); 1265 _current_step = 0; 1266 _current_step_info = ""; 1267 1268 // Run error reporting to determine whether or not to report the crash. 1269 if (!transmit_report_done && should_report_bug(_id)) { 1270 transmit_report_done = true; 1271 const int fd2 = ::dup(log.fd()); 1272 FILE* const hs_err = ::fdopen(fd2, "r"); 1273 if (NULL != hs_err) { 1274 ErrorReporter er; 1275 er.call(hs_err, buffer, O_BUFLEN); 1276 } 1277 ::fclose(hs_err); 1278 } 1279 1280 if (log.fd() != defaultStream::output_fd()) { 1281 close(log.fd()); 1282 } 1283 1284 log.set_fd(-1); 1285 log_done = true; 1286 } 1287 1288 static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay 1289 if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { 1290 skip_replay = true; 1291 ciEnv* env = ciEnv::current(); 1292 if (env != NULL) { 1293 int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", buffer, sizeof(buffer)); 1294 if (fd != -1) { 1295 FILE* replay_data_file = os::open(fd, "w"); 1296 if (replay_data_file != NULL) { 1297 fileStream replay_data_stream(replay_data_file, /*need_close=*/true); 1298 env->dump_replay_data_unsafe(&replay_data_stream); 1299 out.print_raw("#\n# Compiler replay data is saved as:\n# "); 1300 out.print_raw_cr(buffer); 1301 } else { 1302 int e = errno; 1303 out.print_raw("#\n# Can't open file to dump replay data. Error: "); 1304 out.print_raw_cr(os::strerror(e)); 1305 } 1306 } 1307 } 1308 } 1309 1310 static bool skip_bug_url = !should_report_bug(_id); 1311 if (!skip_bug_url) { 1312 skip_bug_url = true; 1313 1314 out.print_raw_cr("#"); 1315 print_bug_submit_message(&out, _thread); 1316 } 1317 1318 static bool skip_OnError = false; 1319 if (!skip_OnError && OnError && OnError[0]) { 1320 skip_OnError = true; 1321 1322 // Flush output and finish logs before running OnError commands. 1323 ostream_abort(); 1324 1325 out.print_raw_cr("#"); 1326 out.print_raw ("# -XX:OnError=\""); 1327 out.print_raw (OnError); 1328 out.print_raw_cr("\""); 1329 1330 char* cmd; 1331 const char* ptr = OnError; 1332 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ 1333 out.print_raw ("# Executing "); 1334 #if defined(LINUX) || defined(_ALLBSD_SOURCE) 1335 out.print_raw ("/bin/sh -c "); 1336 #elif defined(SOLARIS) 1337 out.print_raw ("/usr/bin/sh -c "); 1338 #endif 1339 out.print_raw ("\""); 1340 out.print_raw (cmd); 1341 out.print_raw_cr("\" ..."); 1342 1343 if (os::fork_and_exec(cmd) < 0) { 1344 out.print_cr("os::fork_and_exec failed: %s (%s=%d)", 1345 os::strerror(errno), os::errno_name(errno), errno); 1346 } 1347 } 1348 1349 // done with OnError 1350 OnError = NULL; 1351 } 1352 1353 if (!UseOSErrorReporting) { 1354 // os::abort() will call abort hooks, try it first. 1355 static bool skip_os_abort = false; 1356 if (!skip_os_abort) { 1357 skip_os_abort = true; 1358 bool dump_core = should_report_bug(_id); 1359 os::abort(dump_core && CreateCoredumpOnCrash, _siginfo, _context); 1360 } 1361 1362 // if os::abort() doesn't abort, try os::die(); 1363 os::die(); 1364 } 1365 } 1366 1367 /* 1368 * OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this 1369 * ensures utilities such as jmap can observe the process is a consistent state. 1370 */ 1371 class VM_ReportJavaOutOfMemory : public VM_Operation { 1372 private: 1373 const char* _message; 1374 public: 1375 VM_ReportJavaOutOfMemory(const char* message) { _message = message; } 1376 VMOp_Type type() const { return VMOp_ReportJavaOutOfMemory; } 1377 void doit(); 1378 }; 1379 1380 void VM_ReportJavaOutOfMemory::doit() { 1381 // Don't allocate large buffer on stack 1382 static char buffer[O_BUFLEN]; 1383 1384 tty->print_cr("#"); 1385 tty->print_cr("# java.lang.OutOfMemoryError: %s", _message); 1386 tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError); 1387 1388 // make heap parsability 1389 Universe::heap()->ensure_parsability(false); // no need to retire TLABs 1390 1391 char* cmd; 1392 const char* ptr = OnOutOfMemoryError; 1393 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ 1394 tty->print("# Executing "); 1395 #if defined(LINUX) 1396 tty->print ("/bin/sh -c "); 1397 #elif defined(SOLARIS) 1398 tty->print ("/usr/bin/sh -c "); 1399 #endif 1400 tty->print_cr("\"%s\"...", cmd); 1401 1402 if (os::fork_and_exec(cmd) < 0) { 1403 tty->print_cr("os::fork_and_exec failed: %s (%s=%d)", 1404 os::strerror(errno), os::errno_name(errno), errno); 1405 } 1406 } 1407 } 1408 1409 void VMError::report_java_out_of_memory(const char* message) { 1410 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { 1411 MutexLocker ml(Heap_lock); 1412 VM_ReportJavaOutOfMemory op(message); 1413 VMThread::execute(&op); 1414 } 1415 } 1416 1417 void VMError::show_message_box(char *buf, int buflen) { 1418 bool yes; 1419 do { 1420 error_string(buf, buflen); 1421 yes = os::start_debugging(buf,buflen); 1422 } while (yes); 1423 }