66 // call this when the VM is dying--it might loosen some asserts
67 bool VMError::is_error_reported() { return _error_reported; }
68
69 // returns an address which is guaranteed to generate a SIGSEGV on read,
70 // for test purposes, which is not NULL and contains bits in every word
71 void* VMError::get_segfault_address() {
72 return (void*)
73 #ifdef _LP64
74 0xABC0000000000ABCULL;
75 #else
76 0x00000ABC;
77 #endif
78 }
79
80 // List of environment variables that should be reported in error log file.
81 const char *env_list[] = {
82 // All platforms
83 "JAVA_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
84 "PATH", "USERNAME",
85
86 // Env variables that are defined on Solaris/Linux/BSD
87 "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
88 "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
89 "LANG", "LC_ALL", "LC_CTYPE", "TZ",
90
91 // defined on AIX
92 "LIBPATH", "LDR_PRELOAD", "LDR_PRELOAD64",
93
94 // defined on Linux/AIX/BSD
95 "_JAVA_SR_SIGNUM",
96
97 // defined on Darwin
98 "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
99 "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
100 "DYLD_INSERT_LIBRARIES",
101
102 // defined on Windows
103 "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",
104
105 (const char *)0
106 };
1577 }
1578
1579 static bool skip_OnError = false;
1580 if (!skip_OnError && OnError && OnError[0]) {
1581 skip_OnError = true;
1582
1583 // Flush output and finish logs before running OnError commands.
1584 ostream_abort();
1585
1586 out.print_raw_cr("#");
1587 out.print_raw ("# -XX:OnError=\"");
1588 out.print_raw (OnError);
1589 out.print_raw_cr("\"");
1590
1591 char* cmd;
1592 const char* ptr = OnError;
1593 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
1594 out.print_raw ("# Executing ");
1595 #if defined(LINUX) || defined(_ALLBSD_SOURCE)
1596 out.print_raw ("/bin/sh -c ");
1597 #elif defined(SOLARIS)
1598 out.print_raw ("/usr/bin/sh -c ");
1599 #elif defined(_WINDOWS)
1600 out.print_raw ("cmd /C ");
1601 #endif
1602 out.print_raw ("\"");
1603 out.print_raw (cmd);
1604 out.print_raw_cr("\" ...");
1605
1606 if (os::fork_and_exec(cmd) < 0) {
1607 out.print_cr("os::fork_and_exec failed: %s (%s=%d)",
1608 os::strerror(errno), os::errno_name(errno), errno);
1609 }
1610 }
1611
1612 // done with OnError
1613 OnError = NULL;
1614 }
1615
1616 if (!UseOSErrorReporting) {
1617 // os::abort() will call abort hooks, try it first.
1618 static bool skip_os_abort = false;
1640 void doit();
1641 };
1642
1643 void VM_ReportJavaOutOfMemory::doit() {
1644 // Don't allocate large buffer on stack
1645 static char buffer[O_BUFLEN];
1646
1647 tty->print_cr("#");
1648 tty->print_cr("# java.lang.OutOfMemoryError: %s", _message);
1649 tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError);
1650
1651 // make heap parsability
1652 Universe::heap()->ensure_parsability(false); // no need to retire TLABs
1653
1654 char* cmd;
1655 const char* ptr = OnOutOfMemoryError;
1656 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
1657 tty->print("# Executing ");
1658 #if defined(LINUX)
1659 tty->print ("/bin/sh -c ");
1660 #elif defined(SOLARIS)
1661 tty->print ("/usr/bin/sh -c ");
1662 #endif
1663 tty->print_cr("\"%s\"...", cmd);
1664
1665 if (os::fork_and_exec(cmd, true) < 0) {
1666 tty->print_cr("os::fork_and_exec failed: %s (%s=%d)",
1667 os::strerror(errno), os::errno_name(errno), errno);
1668 }
1669 }
1670 }
1671
1672 void VMError::report_java_out_of_memory(const char* message) {
1673 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
1674 MutexLocker ml(Heap_lock);
1675 VM_ReportJavaOutOfMemory op(message);
1676 VMThread::execute(&op);
1677 }
1678 }
1679
1680 void VMError::show_message_box(char *buf, int buflen) {
1681 bool yes;
|
66 // call this when the VM is dying--it might loosen some asserts
67 bool VMError::is_error_reported() { return _error_reported; }
68
69 // returns an address which is guaranteed to generate a SIGSEGV on read,
70 // for test purposes, which is not NULL and contains bits in every word
71 void* VMError::get_segfault_address() {
72 return (void*)
73 #ifdef _LP64
74 0xABC0000000000ABCULL;
75 #else
76 0x00000ABC;
77 #endif
78 }
79
80 // List of environment variables that should be reported in error log file.
81 const char *env_list[] = {
82 // All platforms
83 "JAVA_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
84 "PATH", "USERNAME",
85
86 // Env variables that are defined on Linux/BSD
87 "LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
88 "HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
89 "LANG", "LC_ALL", "LC_CTYPE", "TZ",
90
91 // defined on AIX
92 "LIBPATH", "LDR_PRELOAD", "LDR_PRELOAD64",
93
94 // defined on Linux/AIX/BSD
95 "_JAVA_SR_SIGNUM",
96
97 // defined on Darwin
98 "DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
99 "DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
100 "DYLD_INSERT_LIBRARIES",
101
102 // defined on Windows
103 "OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",
104
105 (const char *)0
106 };
1577 }
1578
1579 static bool skip_OnError = false;
1580 if (!skip_OnError && OnError && OnError[0]) {
1581 skip_OnError = true;
1582
1583 // Flush output and finish logs before running OnError commands.
1584 ostream_abort();
1585
1586 out.print_raw_cr("#");
1587 out.print_raw ("# -XX:OnError=\"");
1588 out.print_raw (OnError);
1589 out.print_raw_cr("\"");
1590
1591 char* cmd;
1592 const char* ptr = OnError;
1593 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
1594 out.print_raw ("# Executing ");
1595 #if defined(LINUX) || defined(_ALLBSD_SOURCE)
1596 out.print_raw ("/bin/sh -c ");
1597 #elif defined(_WINDOWS)
1598 out.print_raw ("cmd /C ");
1599 #endif
1600 out.print_raw ("\"");
1601 out.print_raw (cmd);
1602 out.print_raw_cr("\" ...");
1603
1604 if (os::fork_and_exec(cmd) < 0) {
1605 out.print_cr("os::fork_and_exec failed: %s (%s=%d)",
1606 os::strerror(errno), os::errno_name(errno), errno);
1607 }
1608 }
1609
1610 // done with OnError
1611 OnError = NULL;
1612 }
1613
1614 if (!UseOSErrorReporting) {
1615 // os::abort() will call abort hooks, try it first.
1616 static bool skip_os_abort = false;
1638 void doit();
1639 };
1640
1641 void VM_ReportJavaOutOfMemory::doit() {
1642 // Don't allocate large buffer on stack
1643 static char buffer[O_BUFLEN];
1644
1645 tty->print_cr("#");
1646 tty->print_cr("# java.lang.OutOfMemoryError: %s", _message);
1647 tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError);
1648
1649 // make heap parsability
1650 Universe::heap()->ensure_parsability(false); // no need to retire TLABs
1651
1652 char* cmd;
1653 const char* ptr = OnOutOfMemoryError;
1654 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
1655 tty->print("# Executing ");
1656 #if defined(LINUX)
1657 tty->print ("/bin/sh -c ");
1658 #endif
1659 tty->print_cr("\"%s\"...", cmd);
1660
1661 if (os::fork_and_exec(cmd, true) < 0) {
1662 tty->print_cr("os::fork_and_exec failed: %s (%s=%d)",
1663 os::strerror(errno), os::errno_name(errno), errno);
1664 }
1665 }
1666 }
1667
1668 void VMError::report_java_out_of_memory(const char* message) {
1669 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
1670 MutexLocker ml(Heap_lock);
1671 VM_ReportJavaOutOfMemory op(message);
1672 VMThread::execute(&op);
1673 }
1674 }
1675
1676 void VMError::show_message_box(char *buf, int buflen) {
1677 bool yes;
|