41 #include "runtime/threadSMR.hpp" 42 #include "runtime/vmThread.hpp" 43 #include "runtime/vm_operations.hpp" 44 #include "runtime/vm_version.hpp" 45 #include "runtime/flags/jvmFlag.hpp" 46 #include "services/memTracker.hpp" 47 #include "utilities/debug.hpp" 48 #include "utilities/decoder.hpp" 49 #include "utilities/defaultStream.hpp" 50 #include "utilities/events.hpp" 51 #include "utilities/vmError.hpp" 52 #include "utilities/macros.hpp" 53 #if INCLUDE_JFR 54 #include "jfr/jfr.hpp" 55 #endif 56 57 #ifndef PRODUCT 58 #include <signal.h> 59 #endif // PRODUCT 60 61 bool VMError::_error_reported = false; 62 63 // call this when the VM is dying--it might loosen some asserts 64 bool VMError::is_error_reported() { return _error_reported; } 65 66 // returns an address which is guaranteed to generate a SIGSEGV on read, 67 // for test purposes, which is not NULL and contains bits in every word 68 void* VMError::get_segfault_address() { 69 return (void*) 70 #ifdef _LP64 71 0xABC0000000000ABCULL; 72 #else 73 0x00000ABC; 74 #endif 75 } 76 77 // List of environment variables that should be reported in error log file. 78 const char *env_list[] = { 79 // All platforms 80 "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH", 1548 static char buffer[O_BUFLEN]; 1549 1550 tty->print_cr("#"); 1551 tty->print_cr("# java.lang.OutOfMemoryError: %s", _message); 1552 tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError); 1553 1554 // make heap parsability 1555 Universe::heap()->ensure_parsability(false); // no need to retire TLABs 1556 1557 char* cmd; 1558 const char* ptr = OnOutOfMemoryError; 1559 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ 1560 tty->print("# Executing "); 1561 #if defined(LINUX) 1562 tty->print ("/bin/sh -c "); 1563 #elif defined(SOLARIS) 1564 tty->print ("/usr/bin/sh -c "); 1565 #endif 1566 tty->print_cr("\"%s\"...", cmd); 1567 1568 if (os::fork_and_exec(cmd) < 0) { 1569 tty->print_cr("os::fork_and_exec failed: %s (%s=%d)", 1570 os::strerror(errno), os::errno_name(errno), errno); 1571 } 1572 } 1573 } 1574 1575 void VMError::report_java_out_of_memory(const char* message) { 1576 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { 1577 MutexLocker ml(Heap_lock); 1578 VM_ReportJavaOutOfMemory op(message); 1579 VMThread::execute(&op); 1580 } 1581 } 1582 1583 void VMError::show_message_box(char *buf, int buflen) { 1584 bool yes; 1585 do { 1586 error_string(buf, buflen); 1587 yes = os::start_debugging(buf,buflen); 1588 } while (yes); 1589 } 1590 1591 // Timeout handling: check if a timeout happened (either a single step did 1592 // timeout or the whole of error reporting hit ErrorLogTimeout). Interrupt | 41 #include "runtime/threadSMR.hpp" 42 #include "runtime/vmThread.hpp" 43 #include "runtime/vm_operations.hpp" 44 #include "runtime/vm_version.hpp" 45 #include "runtime/flags/jvmFlag.hpp" 46 #include "services/memTracker.hpp" 47 #include "utilities/debug.hpp" 48 #include "utilities/decoder.hpp" 49 #include "utilities/defaultStream.hpp" 50 #include "utilities/events.hpp" 51 #include "utilities/vmError.hpp" 52 #include "utilities/macros.hpp" 53 #if INCLUDE_JFR 54 #include "jfr/jfr.hpp" 55 #endif 56 57 #ifndef PRODUCT 58 #include <signal.h> 59 #endif // PRODUCT 60 61 bool VMError::_vfork_mode = false; 62 63 bool VMError::is_forkmode_vfork() { return _vfork_mode; } 64 65 bool VMError::_error_reported = false; 66 67 // call this when the VM is dying--it might loosen some asserts 68 bool VMError::is_error_reported() { return _error_reported; } 69 70 // returns an address which is guaranteed to generate a SIGSEGV on read, 71 // for test purposes, which is not NULL and contains bits in every word 72 void* VMError::get_segfault_address() { 73 return (void*) 74 #ifdef _LP64 75 0xABC0000000000ABCULL; 76 #else 77 0x00000ABC; 78 #endif 79 } 80 81 // List of environment variables that should be reported in error log file. 82 const char *env_list[] = { 83 // All platforms 84 "JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH", 1552 static char buffer[O_BUFLEN]; 1553 1554 tty->print_cr("#"); 1555 tty->print_cr("# java.lang.OutOfMemoryError: %s", _message); 1556 tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError); 1557 1558 // make heap parsability 1559 Universe::heap()->ensure_parsability(false); // no need to retire TLABs 1560 1561 char* cmd; 1562 const char* ptr = OnOutOfMemoryError; 1563 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ 1564 tty->print("# Executing "); 1565 #if defined(LINUX) 1566 tty->print ("/bin/sh -c "); 1567 #elif defined(SOLARIS) 1568 tty->print ("/usr/bin/sh -c "); 1569 #endif 1570 tty->print_cr("\"%s\"...", cmd); 1571 1572 VMError::_vfork_mode = true; 1573 1574 if (os::fork_and_exec(cmd) < 0) { 1575 tty->print_cr("os::fork_and_exec failed: %s (%s=%d)", 1576 os::strerror(errno), os::errno_name(errno), errno); 1577 } 1578 } 1579 1580 VMError::_vfork_mode = false; 1581 } 1582 1583 void VMError::report_java_out_of_memory(const char* message) { 1584 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) { 1585 MutexLocker ml(Heap_lock); 1586 VM_ReportJavaOutOfMemory op(message); 1587 VMThread::execute(&op); 1588 } 1589 } 1590 1591 void VMError::show_message_box(char *buf, int buflen) { 1592 bool yes; 1593 do { 1594 error_string(buf, buflen); 1595 yes = os::start_debugging(buf,buflen); 1596 } while (yes); 1597 } 1598 1599 // Timeout handling: check if a timeout happened (either a single step did 1600 // timeout or the whole of error reporting hit ErrorLogTimeout). Interrupt |