2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2016-01-19 18:39:23 -08:00
|
|
|
* Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-11-17 15:51:46 -05:00
|
|
|
#include <fcntl.h>
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "precompiled.hpp"
|
2014-07-04 11:46:01 +02:00
|
|
|
#include "code/codeCache.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "compiler/compileBroker.hpp"
|
2015-10-08 12:49:30 -10:00
|
|
|
#include "compiler/disassembler.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.hpp"
|
2016-04-19 11:03:37 -04:00
|
|
|
#include "logging/logConfiguration.hpp"
|
2012-02-23 14:58:35 +01:00
|
|
|
#include "prims/whitebox.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/arguments.hpp"
|
2016-08-21 20:56:37 -04:00
|
|
|
#include "runtime/atomic.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/frame.inline.hpp"
|
|
|
|
#include "runtime/init.hpp"
|
|
|
|
#include "runtime/os.hpp"
|
2014-04-29 15:17:27 +02:00
|
|
|
#include "runtime/thread.inline.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "runtime/vmThread.hpp"
|
|
|
|
#include "runtime/vm_operations.hpp"
|
2012-06-28 17:03:16 -04:00
|
|
|
#include "services/memTracker.hpp"
|
2016-06-13 11:48:11 +02:00
|
|
|
#include "trace/traceMacros.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/debug.hpp"
|
2010-12-11 13:20:56 -05:00
|
|
|
#include "utilities/decoder.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/defaultStream.hpp"
|
2011-02-08 17:20:45 -05:00
|
|
|
#include "utilities/errorReporter.hpp"
|
2012-02-01 07:59:01 -08:00
|
|
|
#include "utilities/events.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/vmError.hpp"
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// List of environment variables that should be reported in error log file.
|
|
|
|
const char *env_list[] = {
|
|
|
|
// All platforms
|
|
|
|
"JAVA_HOME", "JRE_HOME", "JAVA_TOOL_OPTIONS", "_JAVA_OPTIONS", "CLASSPATH",
|
|
|
|
"JAVA_COMPILER", "PATH", "USERNAME",
|
|
|
|
|
2011-09-25 16:03:29 -07:00
|
|
|
// Env variables that are defined on Solaris/Linux/BSD
|
2007-12-01 00:00:00 +00:00
|
|
|
"LD_LIBRARY_PATH", "LD_PRELOAD", "SHELL", "DISPLAY",
|
|
|
|
"HOSTTYPE", "OSTYPE", "ARCH", "MACHTYPE",
|
|
|
|
|
|
|
|
// defined on Linux
|
|
|
|
"LD_ASSUME_KERNEL", "_JAVA_SR_SIGNUM",
|
|
|
|
|
2011-09-25 16:03:29 -07:00
|
|
|
// defined on Darwin
|
|
|
|
"DYLD_LIBRARY_PATH", "DYLD_FALLBACK_LIBRARY_PATH",
|
|
|
|
"DYLD_FRAMEWORK_PATH", "DYLD_FALLBACK_FRAMEWORK_PATH",
|
|
|
|
"DYLD_INSERT_LIBRARIES",
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// defined on Windows
|
|
|
|
"OS", "PROCESSOR_IDENTIFIER", "_ALT_JAVA_HOME_DIR",
|
|
|
|
|
|
|
|
(const char *)0
|
|
|
|
};
|
|
|
|
|
|
|
|
// A simple parser for -XX:OnError, usage:
|
|
|
|
// ptr = OnError;
|
|
|
|
// while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr) != NULL)
|
|
|
|
// ... ...
|
|
|
|
static char* next_OnError_command(char* buf, int buflen, const char** ptr) {
|
|
|
|
if (ptr == NULL || *ptr == NULL) return NULL;
|
|
|
|
|
|
|
|
const char* cmd = *ptr;
|
|
|
|
|
|
|
|
// skip leading blanks or ';'
|
|
|
|
while (*cmd == ' ' || *cmd == ';') cmd++;
|
|
|
|
|
|
|
|
if (*cmd == '\0') return NULL;
|
|
|
|
|
|
|
|
const char * cmdend = cmd;
|
|
|
|
while (*cmdend != '\0' && *cmdend != ';') cmdend++;
|
|
|
|
|
|
|
|
Arguments::copy_expand_pid(cmd, cmdend - cmd, buf, buflen);
|
|
|
|
|
|
|
|
*ptr = (*cmdend == '\0' ? cmdend : cmdend + 1);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_bug_submit_message(outputStream *out, Thread *thread) {
|
|
|
|
if (out == NULL) return;
|
|
|
|
out->print_raw_cr("# If you would like to submit a bug report, please visit:");
|
|
|
|
out->print_raw ("# ");
|
|
|
|
out->print_raw_cr(Arguments::java_vendor_url_bug());
|
|
|
|
// If the crash is in native code, encourage user to submit a bug to the
|
|
|
|
// provider of that code.
|
2008-02-27 13:55:58 -05:00
|
|
|
if (thread && thread->is_Java_thread() &&
|
|
|
|
!thread->is_hidden_from_external_view()) {
|
2007-12-01 00:00:00 +00:00
|
|
|
JavaThread* jt = (JavaThread*)thread;
|
|
|
|
if (jt->thread_state() == _thread_in_native) {
|
|
|
|
out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out->print_raw_cr("#");
|
|
|
|
}
|
|
|
|
|
2011-02-09 11:08:10 +01:00
|
|
|
bool VMError::coredump_status;
|
|
|
|
char VMError::coredump_message[O_BUFLEN];
|
|
|
|
|
2015-04-15 17:34:28 -07:00
|
|
|
void VMError::record_coredump_status(const char* message, bool status) {
|
2011-02-09 11:08:10 +01:00
|
|
|
coredump_status = status;
|
|
|
|
strncpy(coredump_message, message, sizeof(coredump_message));
|
|
|
|
coredump_message[sizeof(coredump_message)-1] = 0;
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Return a string to describe the error
|
|
|
|
char* VMError::error_string(char* buf, int buflen) {
|
|
|
|
char signame_buf[64];
|
|
|
|
const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf));
|
|
|
|
|
|
|
|
if (signame) {
|
|
|
|
jio_snprintf(buf, buflen,
|
2015-08-24 15:41:56 -04:00
|
|
|
"%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT,
|
2007-12-01 00:00:00 +00:00
|
|
|
signame, _id, _pc,
|
|
|
|
os::current_process_id(), os::current_thread_id());
|
2010-04-22 13:23:15 -07:00
|
|
|
} else if (_filename != NULL && _lineno > 0) {
|
|
|
|
// skip directory names
|
|
|
|
char separator = os::file_separator()[0];
|
|
|
|
const char *p = strrchr(_filename, separator);
|
|
|
|
int n = jio_snprintf(buf, buflen,
|
2015-08-24 15:41:56 -04:00
|
|
|
"Internal Error at %s:%d, pid=%d, tid=" UINTX_FORMAT,
|
2010-04-22 13:23:15 -07:00
|
|
|
p ? p + 1 : _filename, _lineno,
|
|
|
|
os::current_process_id(), os::current_thread_id());
|
|
|
|
if (n >= 0 && n < buflen && _message) {
|
2015-09-29 11:02:08 +02:00
|
|
|
if (strlen(_detail_msg) > 0) {
|
2010-04-22 13:23:15 -07:00
|
|
|
jio_snprintf(buf + n, buflen - n, "%s%s: %s",
|
2015-09-29 11:02:08 +02:00
|
|
|
os::line_separator(), _message, _detail_msg);
|
2010-04-22 13:23:15 -07:00
|
|
|
} else {
|
|
|
|
jio_snprintf(buf + n, buflen - n, "%sError: %s",
|
|
|
|
os::line_separator(), _message);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2010-04-22 13:23:15 -07:00
|
|
|
} else {
|
|
|
|
jio_snprintf(buf, buflen,
|
2015-08-24 15:41:56 -04:00
|
|
|
"Internal Error (0x%x), pid=%d, tid=" UINTX_FORMAT,
|
2010-04-22 13:23:15 -07:00
|
|
|
_id, os::current_process_id(), os::current_thread_id());
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2010-04-19 02:13:06 -07:00
|
|
|
void VMError::print_stack_trace(outputStream* st, JavaThread* jt,
|
|
|
|
char* buf, int buflen, bool verbose) {
|
|
|
|
#ifdef ZERO
|
|
|
|
if (jt->zero_stack()->sp() && jt->top_zero_frame()) {
|
|
|
|
// StackFrameStream uses the frame anchor, which may not have
|
|
|
|
// been set up. This can be done at any time in Zero, however,
|
|
|
|
// so if it hasn't been set up then we just set it up now and
|
|
|
|
// clear it again when we're done.
|
|
|
|
bool has_last_Java_frame = jt->has_last_Java_frame();
|
|
|
|
if (!has_last_Java_frame)
|
|
|
|
jt->set_last_Java_frame();
|
|
|
|
st->print("Java frames:");
|
|
|
|
|
|
|
|
// If the top frame is a Shark frame and the frame anchor isn't
|
|
|
|
// set up then it's possible that the information in the frame
|
|
|
|
// is garbage: it could be from a previous decache, or it could
|
|
|
|
// simply have never been written. So we print a warning...
|
|
|
|
StackFrameStream sfs(jt);
|
|
|
|
if (!has_last_Java_frame && !sfs.is_done()) {
|
|
|
|
if (sfs.current()->zeroframe()->is_shark_frame()) {
|
|
|
|
st->print(" (TOP FRAME MAY BE JUNK)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
|
|
|
|
// Print the frames
|
|
|
|
for(int i = 0; !sfs.is_done(); sfs.next(), i++) {
|
|
|
|
sfs.current()->zero_print_on_error(i, st, buf, buflen);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reset the frame anchor if necessary
|
|
|
|
if (!has_last_Java_frame)
|
|
|
|
jt->reset_last_Java_frame();
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (jt->has_last_Java_frame()) {
|
|
|
|
st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)");
|
|
|
|
for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) {
|
|
|
|
sfs.current()->print_on_error(st, buf, buflen, verbose);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif // ZERO
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-11-13 16:50:39 -05:00
|
|
|
static void print_oom_reasons(outputStream* st) {
|
2015-07-22 00:03:45 -04:00
|
|
|
st->print_cr("# Possible reasons:");
|
|
|
|
st->print_cr("# The system is out of physical RAM or swap space");
|
2016-07-01 12:51:29 -07:00
|
|
|
if (UseCompressedOops) {
|
|
|
|
st->print_cr("# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap");
|
|
|
|
}
|
|
|
|
if (LogBytesPerWord == 2) {
|
|
|
|
st->print_cr("# In 32 bit mode, the process size limit was hit");
|
|
|
|
}
|
2015-07-22 00:03:45 -04:00
|
|
|
st->print_cr("# Possible solutions:");
|
|
|
|
st->print_cr("# Reduce memory load on the system");
|
|
|
|
st->print_cr("# Increase physical memory or swap space");
|
|
|
|
st->print_cr("# Check if swap backing store is full");
|
2016-07-01 12:51:29 -07:00
|
|
|
if (LogBytesPerWord == 2) {
|
|
|
|
st->print_cr("# Use 64 bit Java on a 64 bit OS");
|
|
|
|
}
|
2015-07-22 00:03:45 -04:00
|
|
|
st->print_cr("# Decrease Java heap size (-Xmx/-Xms)");
|
|
|
|
st->print_cr("# Decrease number of Java threads");
|
|
|
|
st->print_cr("# Decrease Java thread stack sizes (-Xss)");
|
|
|
|
st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize=");
|
2016-07-01 12:51:29 -07:00
|
|
|
if (UseCompressedOops) {
|
|
|
|
switch (Universe::narrow_oop_mode()) {
|
|
|
|
case Universe::UnscaledNarrowOop:
|
|
|
|
st->print_cr("# JVM is running with Unscaled Compressed Oops mode in which the Java heap is");
|
|
|
|
st->print_cr("# placed in the first 4GB address space. The Java Heap base address is the");
|
|
|
|
st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress");
|
|
|
|
st->print_cr("# to set the Java Heap base and to place the Java Heap above 4GB virtual address.");
|
|
|
|
break;
|
|
|
|
case Universe::ZeroBasedNarrowOop:
|
|
|
|
st->print_cr("# JVM is running with Zero Based Compressed Oops mode in which the Java heap is");
|
|
|
|
st->print_cr("# placed in the first 32GB address space. The Java Heap base address is the");
|
|
|
|
st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress");
|
|
|
|
st->print_cr("# to set the Java Heap base and to place the Java Heap above 32GB virtual address.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-07-22 00:03:45 -04:00
|
|
|
st->print_cr("# This output file may be truncated or incomplete.");
|
|
|
|
}
|
|
|
|
|
2015-11-13 16:50:39 -05:00
|
|
|
static const char* gc_mode() {
|
2015-07-22 00:03:45 -04:00
|
|
|
if (UseG1GC) return "g1 gc";
|
|
|
|
if (UseParallelGC) return "parallel gc";
|
|
|
|
if (UseConcMarkSweepGC) return "concurrent mark sweep gc";
|
|
|
|
if (UseSerialGC) return "serial gc";
|
|
|
|
return "ERROR in GC mode";
|
|
|
|
}
|
|
|
|
|
2015-11-13 16:50:39 -05:00
|
|
|
static void report_vm_version(outputStream* st, char* buf, int buflen) {
|
|
|
|
// VM version
|
|
|
|
st->print_cr("#");
|
|
|
|
JDK_Version::current().to_string(buf, buflen);
|
|
|
|
const char* runtime_name = JDK_Version::runtime_name() != NULL ?
|
|
|
|
JDK_Version::runtime_name() : "";
|
|
|
|
const char* runtime_version = JDK_Version::runtime_version() != NULL ?
|
2016-01-19 18:39:23 -08:00
|
|
|
JDK_Version::runtime_version() : "";
|
|
|
|
const char* jdk_debug_level = Abstract_VM_Version::printable_jdk_debug_level() != NULL ?
|
|
|
|
Abstract_VM_Version::printable_jdk_debug_level() : "";
|
|
|
|
|
|
|
|
st->print_cr("# JRE version: %s (%s) (%sbuild %s)", runtime_name, buf,
|
|
|
|
jdk_debug_level, runtime_version);
|
|
|
|
|
2015-11-13 16:50:39 -05:00
|
|
|
// This is the long version with some default settings added
|
2016-01-19 18:39:23 -08:00
|
|
|
st->print_cr("# Java VM: %s (%s%s, %s%s%s%s%s, %s, %s)",
|
2015-11-13 16:50:39 -05:00
|
|
|
Abstract_VM_Version::vm_name(),
|
2016-01-19 18:39:23 -08:00
|
|
|
jdk_debug_level,
|
2015-11-13 16:50:39 -05:00
|
|
|
Abstract_VM_Version::vm_release(),
|
|
|
|
Abstract_VM_Version::vm_info_string(),
|
|
|
|
TieredCompilation ? ", tiered" : "",
|
|
|
|
#if INCLUDE_JVMCI
|
|
|
|
EnableJVMCI ? ", jvmci" : "",
|
|
|
|
UseJVMCICompiler ? ", jvmci compiler" : "",
|
|
|
|
#else
|
|
|
|
"", "",
|
|
|
|
#endif
|
|
|
|
UseCompressedOops ? ", compressed oops" : "",
|
|
|
|
gc_mode(),
|
|
|
|
Abstract_VM_Version::vm_platform_string()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// This is the main function to report a fatal error. Only one thread can
|
|
|
|
// call this function, so we don't need to worry about MT-safety. But it's
|
|
|
|
// possible that the error handler itself may crash or die on an internal
|
|
|
|
// error, for example, when the stack/heap is badly damaged. We must be
|
|
|
|
// able to handle recursive errors that happen inside error handler.
|
|
|
|
//
|
|
|
|
// Error reporting is done in several steps. If a crash or internal error
|
|
|
|
// occurred when reporting an error, the nested signal/exception handler
|
|
|
|
// can skip steps that are already (or partially) done. Error reporting will
|
|
|
|
// continue from the next step. This allows us to retrieve and print
|
|
|
|
// information that may be unsafe to get after a fatal error. If it happens,
|
|
|
|
// you may find nested report_and_die() frames when you look at the stack
|
|
|
|
// in a debugger.
|
|
|
|
//
|
|
|
|
// In general, a hang in error handler is much worse than a crash or internal
|
|
|
|
// error, as it's harder to recover from a hang. Deadlock can happen if we
|
|
|
|
// try to grab a lock that is already owned by current thread, or if the
|
|
|
|
// owner is blocked forever (e.g. in os::infinite_sleep()). If possible, the
|
|
|
|
// error handler and all the functions it called should avoid grabbing any
|
|
|
|
// lock. An important thing to notice is that memory allocation needs a lock.
|
|
|
|
//
|
|
|
|
// We should avoid using large stack allocated buffers. Many errors happen
|
|
|
|
// when stack space is already low. Making things even worse is that there
|
|
|
|
// could be nested report_and_die() calls on stack (see above). Only one
|
|
|
|
// thread can report error, so large buffers are statically allocated in data
|
|
|
|
// segment.
|
|
|
|
|
2015-09-29 11:02:08 +02:00
|
|
|
int VMError::_current_step;
|
|
|
|
const char* VMError::_current_step_info;
|
|
|
|
|
|
|
|
void VMError::report(outputStream* st, bool _verbose) {
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
# define BEGIN if (_current_step == 0) { _current_step = __LINE__;
|
|
|
|
# define STEP(s) } if (_current_step < __LINE__) { _current_step = __LINE__; _current_step_info = s;
|
2007-12-01 00:00:00 +00:00
|
|
|
# define END }
|
|
|
|
|
|
|
|
// don't allocate large buffer on stack
|
|
|
|
static char buf[O_BUFLEN];
|
|
|
|
|
|
|
|
BEGIN
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing fatal error message")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-01-03 14:09:11 -05:00
|
|
|
st->print_cr("#");
|
|
|
|
if (should_report_bug(_id)) {
|
|
|
|
st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
|
|
|
|
} else {
|
|
|
|
st->print_cr("# There is insufficient memory for the Java "
|
|
|
|
"Runtime Environment to continue.");
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-02-04 18:47:42 -05:00
|
|
|
#ifndef PRODUCT
|
|
|
|
// Error handler self tests
|
|
|
|
|
|
|
|
// test secondary error handling. Test it twice, to test that resetting
|
|
|
|
// error handler after a secondary crash works.
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("test secondary crash 1")
|
2015-02-04 18:47:42 -05:00
|
|
|
if (_verbose && TestCrashInErrorHandler != 0) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
|
2015-02-04 18:47:42 -05:00
|
|
|
TestCrashInErrorHandler);
|
|
|
|
controlled_crash(TestCrashInErrorHandler);
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("test secondary crash 2")
|
2015-02-04 18:47:42 -05:00
|
|
|
if (_verbose && TestCrashInErrorHandler != 0) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr("Will crash now (TestCrashInErrorHandler=" UINTX_FORMAT ")...",
|
2015-02-04 18:47:42 -05:00
|
|
|
TestCrashInErrorHandler);
|
|
|
|
controlled_crash(TestCrashInErrorHandler);
|
|
|
|
}
|
2015-03-12 19:34:50 -04:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("test safefetch in error handler")
|
2015-03-12 19:34:50 -04:00
|
|
|
// test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
|
|
|
|
// to test that resetting the signal handler works correctly.
|
|
|
|
if (_verbose && TestSafeFetchInErrorHandler) {
|
|
|
|
st->print_cr("Will test SafeFetch...");
|
|
|
|
if (CanUseSafeFetch32()) {
|
|
|
|
int* const invalid_pointer = (int*) get_segfault_address();
|
|
|
|
const int x = 0x76543210;
|
|
|
|
int i1 = SafeFetch32(invalid_pointer, x);
|
|
|
|
int i2 = SafeFetch32(invalid_pointer, x);
|
|
|
|
if (i1 == x && i2 == x) {
|
|
|
|
st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern
|
|
|
|
} else {
|
|
|
|
st->print_cr("??");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
st->print_cr("not possible; skipped.");
|
|
|
|
}
|
|
|
|
}
|
2015-02-04 18:47:42 -05:00
|
|
|
#endif // PRODUCT
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing type of error")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
switch(_id) {
|
2013-04-30 11:56:52 -07:00
|
|
|
case OOM_MALLOC_ERROR:
|
|
|
|
case OOM_MMAP_ERROR:
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_size) {
|
2013-04-30 11:56:52 -07:00
|
|
|
st->print("# Native memory allocation ");
|
|
|
|
st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
|
|
|
|
"(mmap) failed to map ");
|
2011-01-03 14:09:11 -05:00
|
|
|
jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
|
2014-05-09 16:50:54 -04:00
|
|
|
st->print("%s", buf);
|
2007-12-01 00:00:00 +00:00
|
|
|
st->print(" bytes");
|
2015-09-29 11:02:08 +02:00
|
|
|
if (strlen(_detail_msg) > 0) {
|
2007-12-01 00:00:00 +00:00
|
|
|
st->print(" for ");
|
2015-09-29 11:02:08 +02:00
|
|
|
st->print("%s", _detail_msg);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2011-01-03 14:09:11 -05:00
|
|
|
st->cr();
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2015-09-29 11:02:08 +02:00
|
|
|
if (strlen(_detail_msg) > 0) {
|
2011-01-03 14:09:11 -05:00
|
|
|
st->print("# ");
|
2015-09-29 11:02:08 +02:00
|
|
|
st->print_cr("%s", _detail_msg);
|
2015-06-29 10:16:48 +02:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2011-01-03 14:09:11 -05:00
|
|
|
// In error file give some solutions
|
|
|
|
if (_verbose) {
|
2015-07-22 00:03:45 -04:00
|
|
|
print_oom_reasons(st);
|
2011-01-03 14:09:11 -05:00
|
|
|
} else {
|
|
|
|
return; // that's enough for the screen
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
break;
|
2013-04-30 11:56:52 -07:00
|
|
|
case INTERNAL_ERROR:
|
2007-12-01 00:00:00 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing exception/signal name")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
st->print_cr("#");
|
|
|
|
st->print("# ");
|
|
|
|
// Is it an OS exception/signal?
|
|
|
|
if (os::exception_name(_id, buf, sizeof(buf))) {
|
|
|
|
st->print("%s", buf);
|
|
|
|
st->print(" (0x%x)", _id); // signal number
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print(" at pc=" PTR_FORMAT, p2i(_pc));
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2011-01-03 14:09:11 -05:00
|
|
|
if (should_report_bug(_id)) {
|
|
|
|
st->print("Internal Error");
|
|
|
|
} else {
|
|
|
|
st->print("Out of Memory Error");
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_filename != NULL && _lineno > 0) {
|
|
|
|
#ifdef PRODUCT
|
|
|
|
// In product mode chop off pathname?
|
|
|
|
char separator = os::file_separator()[0];
|
|
|
|
const char *p = strrchr(_filename, separator);
|
|
|
|
const char *file = p ? p+1 : _filename;
|
|
|
|
#else
|
|
|
|
const char *file = _filename;
|
|
|
|
#endif
|
2015-04-07 14:19:03 +02:00
|
|
|
st->print(" (%s:%d)", file, _lineno);
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
|
|
|
st->print(" (0x%x)", _id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing current thread and pid")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// process id, thread id
|
|
|
|
st->print(", pid=%d", os::current_process_id());
|
2015-08-24 15:41:56 -04:00
|
|
|
st->print(", tid=" UINTX_FORMAT, os::current_thread_id());
|
2007-12-01 00:00:00 +00:00
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing error message")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-01-03 14:09:11 -05:00
|
|
|
if (should_report_bug(_id)) { // already printed the message.
|
|
|
|
// error message
|
2015-09-29 11:02:08 +02:00
|
|
|
if (strlen(_detail_msg) > 0) {
|
2011-01-03 14:09:11 -05:00
|
|
|
st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg);
|
|
|
|
} else if (_message) {
|
|
|
|
st->print_cr("# Error: %s", _message);
|
|
|
|
}
|
2015-09-29 11:02:08 +02:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing Java version string")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-11-13 16:50:39 -05:00
|
|
|
report_vm_version(st, buf, sizeof(buf));
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing problematic frame")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Print current frame if we have a context (i.e. it's a crash)
|
|
|
|
if (_context) {
|
|
|
|
st->print_cr("# Problematic frame:");
|
|
|
|
st->print("# ");
|
|
|
|
frame fr = os::fetch_frame_from_context(_context);
|
|
|
|
fr.print_on_error(st, buf, sizeof(buf));
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("#");
|
|
|
|
}
|
2015-07-22 00:03:45 -04:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing core file information")
|
2011-02-09 11:08:10 +01:00
|
|
|
st->print("# ");
|
2015-04-15 17:34:28 -07:00
|
|
|
if (CreateCoredumpOnCrash) {
|
|
|
|
if (coredump_status) {
|
2015-05-12 13:17:54 -07:00
|
|
|
st->print("Core dump will be written. Default location: %s", coredump_message);
|
2015-04-15 17:34:28 -07:00
|
|
|
} else {
|
|
|
|
st->print("No core dump will be written. %s", coredump_message);
|
|
|
|
}
|
2011-02-09 11:08:10 +01:00
|
|
|
} else {
|
2015-04-15 17:34:28 -07:00
|
|
|
st->print("CreateCoredumpOnCrash turned off, no core file dumped");
|
2011-02-09 11:08:10 +01:00
|
|
|
}
|
2014-05-09 16:50:54 -04:00
|
|
|
st->cr();
|
2011-02-09 11:08:10 +01:00
|
|
|
st->print_cr("#");
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing bug submit message")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-01-03 14:09:11 -05:00
|
|
|
if (should_report_bug(_id) && _verbose) {
|
|
|
|
print_bug_submit_message(st, _thread);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing summary")
|
2015-07-22 00:03:45 -04:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("--------------- S U M M A R Y ------------");
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing VM option summary")
|
2015-07-22 00:03:45 -04:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
// VM options
|
|
|
|
Arguments::print_summary_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing summary machine and OS info")
|
2015-07-22 00:03:45 -04:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
os::print_summary_info(st, buf, sizeof(buf));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing date and time")
|
2015-07-22 00:03:45 -04:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
os::print_date_and_time(st, buf, sizeof(buf));
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing thread")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("--------------- T H R E A D ---------------");
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing current thread")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// current thread
|
|
|
|
if (_verbose) {
|
|
|
|
if (_thread) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print("Current thread (" PTR_FORMAT "): ", p2i(_thread));
|
2007-12-01 00:00:00 +00:00
|
|
|
_thread->print_on_error(st, buf, sizeof(buf));
|
|
|
|
st->cr();
|
|
|
|
} else {
|
|
|
|
st->print_cr("Current thread is native thread");
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing current compile task")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2015-07-22 00:03:45 -04:00
|
|
|
if (_verbose && _thread && _thread->is_Compiler_thread()) {
|
|
|
|
CompilerThread* t = (CompilerThread*)_thread;
|
|
|
|
if (t->task()) {
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("Current CompileTask:");
|
|
|
|
t->task()->print_line_on_error(st, buf, sizeof(buf));
|
|
|
|
st->cr();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing stack bounds")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
st->print("Stack: ");
|
|
|
|
|
|
|
|
address stack_top;
|
|
|
|
size_t stack_size;
|
|
|
|
|
|
|
|
if (_thread) {
|
|
|
|
stack_top = _thread->stack_base();
|
|
|
|
stack_size = _thread->stack_size();
|
|
|
|
} else {
|
|
|
|
stack_top = os::current_stack_base();
|
|
|
|
stack_size = os::current_stack_size();
|
|
|
|
}
|
|
|
|
|
|
|
|
address stack_bottom = stack_top - stack_size;
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print("[" PTR_FORMAT "," PTR_FORMAT "]", p2i(stack_bottom), p2i(stack_top));
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
frame fr = _context ? os::fetch_frame_from_context(_context)
|
|
|
|
: os::current_frame();
|
|
|
|
|
|
|
|
if (fr.sp()) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print(", sp=" PTR_FORMAT, p2i(fr.sp()));
|
2010-07-30 10:21:15 -07:00
|
|
|
size_t free_stack_size = pointer_delta(fr.sp(), stack_bottom, 1024);
|
|
|
|
st->print(", free space=" SIZE_FORMAT "k", free_stack_size);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing native stack")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2014-09-24 12:19:07 -07:00
|
|
|
if (_verbose) {
|
2013-09-06 08:42:42 -07:00
|
|
|
if (os::platform_print_native_stack(st, _context, buf, sizeof(buf))) {
|
|
|
|
// We have printed the native stack in platform-specific code
|
|
|
|
// Windows/x64 needs special handling.
|
|
|
|
} else {
|
2007-12-01 00:00:00 +00:00
|
|
|
frame fr = _context ? os::fetch_frame_from_context(_context)
|
|
|
|
: os::current_frame();
|
|
|
|
|
2014-09-24 12:19:07 -07:00
|
|
|
print_native_stack(st, fr, _thread, buf, sizeof(buf));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2013-09-06 08:42:42 -07:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing Java stack")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose && _thread && _thread->is_Java_thread()) {
|
2010-04-19 02:13:06 -07:00
|
|
|
print_stack_trace(st, (JavaThread*)_thread, buf, sizeof(buf));
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing target Java thread stack")
|
2009-12-11 11:09:49 -08:00
|
|
|
|
|
|
|
// printing Java thread stack trace if it is involved in GC crash
|
2010-10-21 11:55:10 -07:00
|
|
|
if (_verbose && _thread && (_thread->is_Named_thread())) {
|
2009-12-11 11:09:49 -08:00
|
|
|
JavaThread* jt = ((NamedThread *)_thread)->processed_thread();
|
|
|
|
if (jt != NULL) {
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr("JavaThread " PTR_FORMAT " (nid = %d) was being processed", p2i(jt), jt->osthread()->thread_id());
|
2010-04-19 02:13:06 -07:00
|
|
|
print_stack_trace(st, jt, buf, sizeof(buf), true);
|
2009-12-11 11:09:49 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing siginfo")
|
2015-07-22 00:03:45 -04:00
|
|
|
|
|
|
|
// signal no, signal code, address that caused the fault
|
|
|
|
if (_verbose && _siginfo) {
|
|
|
|
st->cr();
|
|
|
|
os::print_siginfo(st, _siginfo);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("CDS archive access warning")
|
2015-12-09 14:56:02 +01:00
|
|
|
|
|
|
|
// Print an explicit hint if we crashed on access to the CDS archive.
|
|
|
|
if (_verbose && _siginfo) {
|
|
|
|
check_failing_cds_access(st, _siginfo);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing register info")
|
2015-07-22 00:03:45 -04:00
|
|
|
|
|
|
|
// decode register contents if possible
|
|
|
|
if (_verbose && _context && Universe::is_fully_initialized()) {
|
|
|
|
os::print_register_info(st, _context);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing registers, top of stack, instructions near pc")
|
2015-07-22 00:03:45 -04:00
|
|
|
|
|
|
|
// registers, top of stack, instructions near pc
|
|
|
|
if (_verbose && _context) {
|
|
|
|
os::print_context(st, _context);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing code blob if possible")
|
2015-10-08 12:49:30 -10:00
|
|
|
|
|
|
|
if (_verbose && _context) {
|
|
|
|
CodeBlob* cb = CodeCache::find_blob(_pc);
|
|
|
|
if (cb != NULL) {
|
|
|
|
if (Interpreter::contains(_pc)) {
|
|
|
|
// The interpreter CodeBlob is very large so try to print the codelet instead.
|
|
|
|
InterpreterCodelet* codelet = Interpreter::codelet_containing(_pc);
|
|
|
|
if (codelet != NULL) {
|
|
|
|
codelet->print_on(st);
|
|
|
|
Disassembler::decode(codelet->code_begin(), codelet->code_end(), st);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
StubCodeDesc* desc = StubCodeDesc::desc_for(_pc);
|
|
|
|
if (desc != NULL) {
|
|
|
|
desc->print_on(st);
|
|
|
|
Disassembler::decode(desc->begin(), desc->end(), st);
|
|
|
|
} else {
|
|
|
|
Disassembler::decode(cb, st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing VM operation")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose && _thread && _thread->is_VM_thread()) {
|
|
|
|
VMThread* t = (VMThread*)_thread;
|
|
|
|
VM_Operation* op = t->vm_operation();
|
|
|
|
if (op) {
|
|
|
|
op->print_on_error(st);
|
|
|
|
st->cr();
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing process")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("--------------- P R O C E S S ---------------");
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing all threads")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// all threads
|
|
|
|
if (_verbose && _thread) {
|
|
|
|
Threads::print_on_error(st, _thread, buf, sizeof(buf));
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing VM state")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
// Safepoint state
|
|
|
|
st->print("VM state:");
|
|
|
|
|
|
|
|
if (SafepointSynchronize::is_synchronizing()) st->print("synchronizing");
|
|
|
|
else if (SafepointSynchronize::is_at_safepoint()) st->print("at safepoint");
|
|
|
|
else st->print("not at safepoint");
|
|
|
|
|
|
|
|
// Also see if error occurred during initialization or shutdown
|
|
|
|
if (!Universe::is_fully_initialized()) {
|
|
|
|
st->print(" (not fully initialized)");
|
|
|
|
} else if (VM_Exit::vm_exited()) {
|
|
|
|
st->print(" (shutting down)");
|
|
|
|
} else {
|
|
|
|
st->print(" (normal execution)");
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing owned locks on error")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// mutexes/monitors that currently have an owner
|
|
|
|
if (_verbose) {
|
|
|
|
print_owned_locks_on_error(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing number of OutOfMemoryError and StackOverflow exceptions")
|
2015-06-09 10:26:25 -04:00
|
|
|
|
|
|
|
if (_verbose && Exceptions::has_exception_counts()) {
|
|
|
|
st->print_cr("OutOfMemory and StackOverflow Exception counts:");
|
|
|
|
Exceptions::print_exception_counts_on_error(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing compressed oops mode")
|
2015-06-09 10:26:25 -04:00
|
|
|
|
|
|
|
if (_verbose && UseCompressedOops) {
|
|
|
|
Universe::print_compressed_oops_mode(st);
|
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
Metaspace::print_compressed_class_space(st);
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing heap information")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose && Universe::is_fully_initialized()) {
|
2013-04-10 14:26:49 +02:00
|
|
|
Universe::heap()->print_on_error(st);
|
2012-04-02 16:05:56 -07:00
|
|
|
st->cr();
|
2015-10-09 09:42:33 +02:00
|
|
|
st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page()));
|
2012-04-02 16:05:56 -07:00
|
|
|
st->cr();
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing code cache information")
|
2010-10-21 11:55:10 -07:00
|
|
|
|
|
|
|
if (_verbose && Universe::is_fully_initialized()) {
|
|
|
|
// print code cache information before vm abort
|
2013-01-14 13:52:08 -05:00
|
|
|
CodeCache::print_summary(st);
|
2010-10-21 11:55:10 -07:00
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing ring buffers")
|
2012-02-01 07:59:01 -08:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
Events::print_all(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing dynamic libraries")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
// dynamic libraries, or memory map
|
|
|
|
os::print_dll_info(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing VM options")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
// VM options
|
|
|
|
Arguments::print_on(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing warning if internal testing API used")
|
2012-02-23 14:58:35 +01:00
|
|
|
|
|
|
|
if (WhiteBox::used()) {
|
|
|
|
st->print_cr("Unsupported internal testing APIs have been used.");
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing log configuration")
|
2016-04-19 11:03:37 -04:00
|
|
|
if (_verbose){
|
|
|
|
st->print_cr("Logging:");
|
|
|
|
LogConfiguration::describe_current_configuration(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing all environment variables")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
2015-03-30 17:32:18 -04:00
|
|
|
os::print_environment_variables(st, env_list);
|
2007-12-01 00:00:00 +00:00
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing signal handlers")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
os::print_signal_handlers(st, buf, sizeof(buf));
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("Native Memory Tracking")
|
2014-08-07 12:18:58 -07:00
|
|
|
if (_verbose) {
|
2014-10-10 19:36:12 +00:00
|
|
|
MemTracker::error_report(st);
|
2014-08-07 12:18:58 -07:00
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing system")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("--------------- S Y S T E M ---------------");
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing OS information")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
os::print_os_info(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing CPU info")
|
2007-12-01 00:00:00 +00:00
|
|
|
if (_verbose) {
|
2015-06-17 11:30:51 -04:00
|
|
|
os::print_cpu_info(st, buf, sizeof(buf));
|
2007-12-01 00:00:00 +00:00
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing memory info")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
os::print_memory_info(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing internal vm info")
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2015-02-04 18:47:42 -05:00
|
|
|
// print a defined marker to show that error handling finished correctly.
|
2016-04-28 15:40:45 +02:00
|
|
|
STEP("printing end marker")
|
2015-02-04 18:47:42 -05:00
|
|
|
|
|
|
|
if (_verbose) {
|
|
|
|
st->print_cr("END.");
|
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
END
|
|
|
|
|
|
|
|
# undef BEGIN
|
|
|
|
# undef STEP
|
|
|
|
# undef END
|
|
|
|
}
|
|
|
|
|
2015-11-13 16:50:39 -05:00
|
|
|
// Report for the vm_info_cmd. This prints out the information above omitting
|
|
|
|
// crash and thread specific information. If output is added above, it should be added
|
|
|
|
// here also, if it is safe to call during a running process.
|
|
|
|
void VMError::print_vm_info(outputStream* st) {
|
|
|
|
|
|
|
|
char buf[O_BUFLEN];
|
|
|
|
report_vm_version(st, buf, sizeof(buf));
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing summary")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("--------------- S U M M A R Y ------------");
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing VM option summary")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
// VM options
|
|
|
|
Arguments::print_summary_on(st);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing summary machine and OS info")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
os::print_summary_info(st, buf, sizeof(buf));
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing date and time")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
os::print_date_and_time(st, buf, sizeof(buf));
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// Skip: STEP("printing thread")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing process")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("--------------- P R O C E S S ---------------");
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing number of OutOfMemoryError and StackOverflow exceptions")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
if (Exceptions::has_exception_counts()) {
|
|
|
|
st->print_cr("OutOfMemory and StackOverflow Exception counts:");
|
|
|
|
Exceptions::print_exception_counts_on_error(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing compressed oops mode")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
if (UseCompressedOops) {
|
|
|
|
Universe::print_compressed_oops_mode(st);
|
|
|
|
if (UseCompressedClassPointers) {
|
|
|
|
Metaspace::print_compressed_class_space(st);
|
|
|
|
}
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing heap information")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
if (Universe::is_fully_initialized()) {
|
2016-06-21 09:19:53 +02:00
|
|
|
MutexLocker hl(Heap_lock);
|
2015-11-13 16:50:39 -05:00
|
|
|
Universe::heap()->print_on_error(st);
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("Polling page: " INTPTR_FORMAT, p2i(os::get_polling_page()));
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing code cache information")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
if (Universe::is_fully_initialized()) {
|
|
|
|
// print code cache information before vm abort
|
|
|
|
CodeCache::print_summary(st);
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing ring buffers")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
Events::print_all(st);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing dynamic libraries")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
// dynamic libraries, or memory map
|
|
|
|
os::print_dll_info(st);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing VM options")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
// VM options
|
|
|
|
Arguments::print_on(st);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing warning if internal testing API used")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
if (WhiteBox::used()) {
|
|
|
|
st->print_cr("Unsupported internal testing APIs have been used.");
|
|
|
|
st->cr();
|
|
|
|
}
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing log configuration")
|
2016-04-19 11:03:37 -04:00
|
|
|
st->print_cr("Logging:");
|
|
|
|
LogConfiguration::describe(st);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing all environment variables")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
os::print_environment_variables(st, env_list);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing signal handlers")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
os::print_signal_handlers(st, buf, sizeof(buf));
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("Native Memory Tracking")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
MemTracker::error_report(st);
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing system")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
st->cr();
|
|
|
|
st->print_cr("--------------- S Y S T E M ---------------");
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing OS information")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
os::print_os_info(st);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing CPU info")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
os::print_cpu_info(st, buf, sizeof(buf));
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing memory info")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
os::print_memory_info(st);
|
|
|
|
st->cr();
|
|
|
|
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing internal vm info")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
|
|
|
|
st->cr();
|
|
|
|
|
|
|
|
// print a defined marker to show that error handling finished correctly.
|
2016-04-28 15:40:45 +02:00
|
|
|
// STEP("printing end marker")
|
2015-11-13 16:50:39 -05:00
|
|
|
|
|
|
|
st->print_cr("END.");
|
|
|
|
}
|
|
|
|
|
2015-10-07 15:27:02 +02:00
|
|
|
volatile intptr_t VMError::first_error_tid = -1;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-07-01 09:13:19 +00:00
|
|
|
// An error could happen before tty is initialized or after it has been
|
2016-01-27 11:51:56 +01:00
|
|
|
// destroyed.
|
|
|
|
// Please note: to prevent large stack allocations, the log- and
|
|
|
|
// output-stream use a global scratch buffer for format printing.
|
|
|
|
// (see VmError::report_and_die(). Access to those streams is synchronized
|
|
|
|
// in VmError::report_and_die() - there is only one reporting thread at
|
|
|
|
// any given time.
|
2013-07-01 09:13:19 +00:00
|
|
|
fdStream VMError::out(defaultStream::output_fd());
|
|
|
|
fdStream VMError::log; // error log used by VMError::report_and_die()
|
|
|
|
|
2013-04-25 11:02:32 -07:00
|
|
|
/** Expand a pattern into a buffer starting at pos and open a file using constructed path */
|
|
|
|
static int expand_and_open(const char* pattern, char* buf, size_t buflen, size_t pos) {
|
|
|
|
int fd = -1;
|
|
|
|
if (Arguments::copy_expand_pid(pattern, strlen(pattern), &buf[pos], buflen - pos)) {
|
2014-11-17 15:51:46 -05:00
|
|
|
// the O_EXCL flag will cause the open to fail if the file exists
|
|
|
|
fd = open(buf, O_RDWR | O_CREAT | O_EXCL, 0666);
|
2013-04-25 11:02:32 -07:00
|
|
|
}
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Construct file name for a log file and return it's file descriptor.
|
|
|
|
* Name and location depends on pattern, default_pattern params and access
|
|
|
|
* permissions.
|
|
|
|
*/
|
|
|
|
static int prepare_log_file(const char* pattern, const char* default_pattern, char* buf, size_t buflen) {
|
|
|
|
int fd = -1;
|
|
|
|
|
|
|
|
// If possible, use specified pattern to construct log file name
|
|
|
|
if (pattern != NULL) {
|
|
|
|
fd = expand_and_open(pattern, buf, buflen, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Either user didn't specify, or the user's location failed,
|
|
|
|
// so use the default name in the current directory
|
|
|
|
if (fd == -1) {
|
|
|
|
const char* cwd = os::get_current_directory(buf, buflen);
|
|
|
|
if (cwd != NULL) {
|
|
|
|
size_t pos = strlen(cwd);
|
|
|
|
int fsep_len = jio_snprintf(&buf[pos], buflen-pos, "%s", os::file_separator());
|
|
|
|
pos += fsep_len;
|
|
|
|
if (fsep_len > 0) {
|
|
|
|
fd = expand_and_open(default_pattern, buf, buflen, pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// try temp directory if it exists.
|
|
|
|
if (fd == -1) {
|
|
|
|
const char* tmpdir = os::get_temp_directory();
|
|
|
|
if (tmpdir != NULL && strlen(tmpdir) > 0) {
|
|
|
|
int pos = jio_snprintf(buf, buflen, "%s%s", tmpdir, os::file_separator());
|
|
|
|
if (pos > 0) {
|
|
|
|
fd = expand_and_open(default_pattern, buf, buflen, pos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return fd;
|
|
|
|
}
|
|
|
|
|
2015-09-29 11:02:08 +02:00
|
|
|
int VMError::_id;
|
|
|
|
const char* VMError::_message;
|
|
|
|
char VMError::_detail_msg[1024];
|
|
|
|
Thread* VMError::_thread;
|
|
|
|
address VMError::_pc;
|
|
|
|
void* VMError::_siginfo;
|
|
|
|
void* VMError::_context;
|
|
|
|
const char* VMError::_filename;
|
|
|
|
int VMError::_lineno;
|
|
|
|
size_t VMError::_size;
|
|
|
|
|
|
|
|
void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo,
|
|
|
|
void* context, const char* detail_fmt, ...)
|
|
|
|
{
|
|
|
|
va_list detail_args;
|
|
|
|
va_start(detail_args, detail_fmt);
|
|
|
|
report_and_die(sig, NULL, detail_fmt, detail_args, thread, pc, siginfo, context, NULL, 0, 0);
|
|
|
|
va_end(detail_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context)
|
|
|
|
{
|
|
|
|
report_and_die(thread, sig, pc, siginfo, context, "%s", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMError::report_and_die(const char* message, const char* detail_fmt, ...)
|
|
|
|
{
|
|
|
|
va_list detail_args;
|
|
|
|
va_start(detail_args, detail_fmt);
|
|
|
|
report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, NULL, NULL, NULL, NULL, NULL, 0, 0);
|
|
|
|
va_end(detail_args);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMError::report_and_die(const char* message)
|
|
|
|
{
|
|
|
|
report_and_die(message, "%s", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMError::report_and_die(Thread* thread, const char* filename, int lineno, const char* message,
|
|
|
|
const char* detail_fmt, va_list detail_args)
|
|
|
|
{
|
|
|
|
report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
|
|
|
|
VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) {
|
|
|
|
report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
|
|
|
|
Thread* thread, address pc, void* siginfo, void* context, const char* filename,
|
|
|
|
int lineno, size_t size)
|
|
|
|
{
|
2007-12-01 00:00:00 +00:00
|
|
|
// Don't allocate large buffer on stack
|
|
|
|
static char buffer[O_BUFLEN];
|
2016-01-27 11:51:56 +01:00
|
|
|
out.set_scratch_buffer(buffer, sizeof(buffer));
|
|
|
|
log.set_scratch_buffer(buffer, sizeof(buffer));
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// How many errors occurred in error handler when reporting first_error.
|
|
|
|
static int recursive_error_count;
|
|
|
|
|
|
|
|
// We will first print a brief message to standard out (verbose = false),
|
|
|
|
// then save detailed information in log file (verbose = true).
|
|
|
|
static bool out_done = false; // done printing to standard out
|
|
|
|
static bool log_done = false; // done saving error log
|
2011-02-08 17:20:45 -05:00
|
|
|
static bool transmit_report_done = false; // done error reporting
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
if (SuppressFatalErrorMessage) {
|
2015-04-15 17:34:28 -07:00
|
|
|
os::abort(CreateCoredumpOnCrash);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
2015-10-07 15:27:02 +02:00
|
|
|
intptr_t mytid = os::current_thread_id();
|
2015-09-29 11:02:08 +02:00
|
|
|
if (first_error_tid == -1 &&
|
2015-10-07 15:27:02 +02:00
|
|
|
Atomic::cmpxchg_ptr(mytid, &first_error_tid, -1) == -1) {
|
2015-09-29 11:02:08 +02:00
|
|
|
|
2016-02-25 08:47:57 +01:00
|
|
|
// Initialize time stamps to use the same base.
|
|
|
|
out.time_stamp().update_to(1);
|
|
|
|
log.time_stamp().update_to(1);
|
|
|
|
|
2015-09-29 11:02:08 +02:00
|
|
|
_id = id;
|
|
|
|
_message = message;
|
|
|
|
_thread = thread;
|
|
|
|
_pc = pc;
|
|
|
|
_siginfo = siginfo;
|
|
|
|
_context = context;
|
|
|
|
_filename = filename;
|
|
|
|
_lineno = lineno;
|
|
|
|
_size = size;
|
|
|
|
jio_vsnprintf(_detail_msg, sizeof(_detail_msg), detail_fmt, detail_args);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// first time
|
|
|
|
set_error_reported();
|
|
|
|
|
2011-02-28 14:19:52 +01:00
|
|
|
if (ShowMessageBoxOnError || PauseAtExit) {
|
2007-12-01 00:00:00 +00:00
|
|
|
show_message_box(buffer, sizeof(buffer));
|
|
|
|
|
|
|
|
// User has asked JVM to abort. Reset ShowMessageBoxOnError so the
|
|
|
|
// WatcherThread can kill JVM if the error handler hangs.
|
|
|
|
ShowMessageBoxOnError = false;
|
|
|
|
}
|
|
|
|
|
2015-04-15 17:34:28 -07:00
|
|
|
os::check_dump_limit(buffer, sizeof(buffer));
|
2011-02-09 11:08:10 +01:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// reset signal handlers or exception filter; make sure recursive crashes
|
|
|
|
// are handled properly.
|
|
|
|
reset_signal_handlers();
|
|
|
|
|
2016-06-13 11:48:11 +02:00
|
|
|
TRACE_VM_ERROR();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
} else {
|
2008-12-23 06:16:53 -08:00
|
|
|
// If UseOsErrorReporting we call this for each level of the call stack
|
|
|
|
// while searching for the exception handler. Only the first level needs
|
|
|
|
// to be reported.
|
|
|
|
if (UseOSErrorReporting && log_done) return;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// This is not the first error, see if it happened in a different thread
|
|
|
|
// or in the same thread during error reporting.
|
|
|
|
if (first_error_tid != mytid) {
|
2013-07-05 08:26:49 +00:00
|
|
|
char msgbuf[64];
|
|
|
|
jio_snprintf(msgbuf, sizeof(msgbuf),
|
2015-10-07 15:27:02 +02:00
|
|
|
"[thread " INTX_FORMAT " also had an error]",
|
2007-12-01 00:00:00 +00:00
|
|
|
mytid);
|
2013-07-05 08:26:49 +00:00
|
|
|
out.print_raw_cr(msgbuf);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// error reporting is not MT-safe, block current thread
|
|
|
|
os::infinite_sleep();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (recursive_error_count++ > 30) {
|
|
|
|
out.print_raw_cr("[Too many errors, abort]");
|
|
|
|
os::die();
|
|
|
|
}
|
|
|
|
|
|
|
|
jio_snprintf(buffer, sizeof(buffer),
|
2016-04-28 15:40:45 +02:00
|
|
|
"[error occurred during error reporting (%s), id 0x%x]",
|
2015-09-29 11:02:08 +02:00
|
|
|
_current_step_info, _id);
|
2007-12-01 00:00:00 +00:00
|
|
|
if (log.is_open()) {
|
|
|
|
log.cr();
|
|
|
|
log.print_raw_cr(buffer);
|
|
|
|
log.cr();
|
|
|
|
} else {
|
|
|
|
out.cr();
|
|
|
|
out.print_raw_cr(buffer);
|
|
|
|
out.cr();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// print to screen
|
|
|
|
if (!out_done) {
|
2016-01-27 11:51:56 +01:00
|
|
|
report(&out, false);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
out_done = true;
|
|
|
|
|
2015-09-29 11:02:08 +02:00
|
|
|
_current_step = 0;
|
|
|
|
_current_step_info = "";
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// print to error log file
|
|
|
|
if (!log_done) {
|
|
|
|
// see if log file is already open
|
|
|
|
if (!log.is_open()) {
|
|
|
|
// open log file
|
2013-04-25 11:02:32 -07:00
|
|
|
int fd = prepare_log_file(ErrorFile, "hs_err_pid%p.log", buffer, sizeof(buffer));
|
2007-12-01 00:00:00 +00:00
|
|
|
if (fd != -1) {
|
|
|
|
out.print_raw("# An error report file with more information is saved as:\n# ");
|
|
|
|
out.print_raw_cr(buffer);
|
|
|
|
|
|
|
|
log.set_fd(fd);
|
|
|
|
} else {
|
|
|
|
out.print_raw_cr("# Can not save log file, dump to screen..");
|
|
|
|
log.set_fd(defaultStream::output_fd());
|
2011-02-08 17:20:45 -05:00
|
|
|
/* Error reporting currently needs dumpfile.
|
|
|
|
* Maybe implement direct streaming in the future.*/
|
|
|
|
transmit_report_done = true;
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-01-27 11:51:56 +01:00
|
|
|
report(&log, true);
|
2015-09-29 11:02:08 +02:00
|
|
|
_current_step = 0;
|
|
|
|
_current_step_info = "";
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2011-02-08 17:20:45 -05:00
|
|
|
// Run error reporting to determine whether or not to report the crash.
|
2015-09-29 11:02:08 +02:00
|
|
|
if (!transmit_report_done && should_report_bug(_id)) {
|
2011-02-08 17:20:45 -05:00
|
|
|
transmit_report_done = true;
|
2014-10-29 10:13:24 +01:00
|
|
|
const int fd2 = ::dup(log.fd());
|
|
|
|
FILE* const hs_err = ::fdopen(fd2, "r");
|
2011-02-08 17:20:45 -05:00
|
|
|
if (NULL != hs_err) {
|
|
|
|
ErrorReporter er;
|
|
|
|
er.call(hs_err, buffer, O_BUFLEN);
|
|
|
|
}
|
2014-10-29 10:13:24 +01:00
|
|
|
::fclose(hs_err);
|
2011-02-08 17:20:45 -05:00
|
|
|
}
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
if (log.fd() != defaultStream::output_fd()) {
|
|
|
|
close(log.fd());
|
|
|
|
}
|
|
|
|
|
|
|
|
log.set_fd(-1);
|
|
|
|
log_done = true;
|
|
|
|
}
|
|
|
|
|
2016-01-15 21:56:42 +03:00
|
|
|
static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay
|
|
|
|
if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) {
|
|
|
|
skip_replay = true;
|
|
|
|
ciEnv* env = ciEnv::current();
|
|
|
|
if (env != NULL) {
|
|
|
|
int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", buffer, sizeof(buffer));
|
|
|
|
if (fd != -1) {
|
|
|
|
FILE* replay_data_file = os::open(fd, "w");
|
|
|
|
if (replay_data_file != NULL) {
|
|
|
|
fileStream replay_data_stream(replay_data_file, /*need_close=*/true);
|
|
|
|
env->dump_replay_data_unsafe(&replay_data_stream);
|
|
|
|
out.print_raw("#\n# Compiler replay data is saved as:\n# ");
|
|
|
|
out.print_raw_cr(buffer);
|
|
|
|
} else {
|
2016-03-12 08:35:05 +01:00
|
|
|
int e = errno;
|
2016-01-15 21:56:42 +03:00
|
|
|
out.print_raw("#\n# Can't open file to dump replay data. Error: ");
|
2016-03-12 08:35:05 +01:00
|
|
|
out.print_raw_cr(os::strerror(e));
|
2016-01-15 21:56:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool skip_bug_url = !should_report_bug(_id);
|
|
|
|
if (!skip_bug_url) {
|
|
|
|
skip_bug_url = true;
|
|
|
|
|
|
|
|
out.print_raw_cr("#");
|
|
|
|
print_bug_submit_message(&out, _thread);
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
static bool skip_OnError = false;
|
|
|
|
if (!skip_OnError && OnError && OnError[0]) {
|
|
|
|
skip_OnError = true;
|
|
|
|
|
2016-01-15 21:56:42 +03:00
|
|
|
// Flush output and finish logs before running OnError commands.
|
|
|
|
ostream_abort();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
out.print_raw_cr("#");
|
|
|
|
out.print_raw ("# -XX:OnError=\"");
|
|
|
|
out.print_raw (OnError);
|
|
|
|
out.print_raw_cr("\"");
|
|
|
|
|
|
|
|
char* cmd;
|
|
|
|
const char* ptr = OnError;
|
|
|
|
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
|
|
|
|
out.print_raw ("# Executing ");
|
2011-09-25 16:03:29 -07:00
|
|
|
#if defined(LINUX) || defined(_ALLBSD_SOURCE)
|
2007-12-01 00:00:00 +00:00
|
|
|
out.print_raw ("/bin/sh -c ");
|
|
|
|
#elif defined(SOLARIS)
|
|
|
|
out.print_raw ("/usr/bin/sh -c ");
|
|
|
|
#endif
|
|
|
|
out.print_raw ("\"");
|
|
|
|
out.print_raw (cmd);
|
|
|
|
out.print_raw_cr("\" ...");
|
|
|
|
|
2015-05-12 20:55:40 -04:00
|
|
|
if (os::fork_and_exec(cmd) < 0) {
|
2016-03-12 08:35:05 +01:00
|
|
|
out.print_cr("os::fork_and_exec failed: %s (%s=%d)",
|
|
|
|
os::strerror(errno), os::errno_name(errno), errno);
|
2015-05-12 20:55:40 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// done with OnError
|
|
|
|
OnError = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!UseOSErrorReporting) {
|
|
|
|
// os::abort() will call abort hooks, try it first.
|
|
|
|
static bool skip_os_abort = false;
|
|
|
|
if (!skip_os_abort) {
|
|
|
|
skip_os_abort = true;
|
2015-09-29 11:02:08 +02:00
|
|
|
bool dump_core = should_report_bug(_id);
|
2015-04-15 17:34:28 -07:00
|
|
|
os::abort(dump_core && CreateCoredumpOnCrash, _siginfo, _context);
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// if os::abort() doesn't abort, try os::die();
|
|
|
|
os::die();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this
|
|
|
|
* ensures utilities such as jmap can observe the process is a consistent state.
|
|
|
|
*/
|
|
|
|
class VM_ReportJavaOutOfMemory : public VM_Operation {
|
|
|
|
private:
|
2015-09-29 11:02:08 +02:00
|
|
|
const char* _message;
|
2007-12-01 00:00:00 +00:00
|
|
|
public:
|
2015-09-29 11:02:08 +02:00
|
|
|
VM_ReportJavaOutOfMemory(const char* message) { _message = message; }
|
|
|
|
VMOp_Type type() const { return VMOp_ReportJavaOutOfMemory; }
|
2007-12-01 00:00:00 +00:00
|
|
|
void doit();
|
|
|
|
};
|
|
|
|
|
|
|
|
void VM_ReportJavaOutOfMemory::doit() {
|
|
|
|
// Don't allocate large buffer on stack
|
|
|
|
static char buffer[O_BUFLEN];
|
|
|
|
|
|
|
|
tty->print_cr("#");
|
2015-09-29 11:02:08 +02:00
|
|
|
tty->print_cr("# java.lang.OutOfMemoryError: %s", _message);
|
2007-12-01 00:00:00 +00:00
|
|
|
tty->print_cr("# -XX:OnOutOfMemoryError=\"%s\"", OnOutOfMemoryError);
|
|
|
|
|
|
|
|
// make heap parsability
|
|
|
|
Universe::heap()->ensure_parsability(false); // no need to retire TLABs
|
|
|
|
|
|
|
|
char* cmd;
|
|
|
|
const char* ptr = OnOutOfMemoryError;
|
|
|
|
while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){
|
|
|
|
tty->print("# Executing ");
|
|
|
|
#if defined(LINUX)
|
|
|
|
tty->print ("/bin/sh -c ");
|
|
|
|
#elif defined(SOLARIS)
|
|
|
|
tty->print ("/usr/bin/sh -c ");
|
|
|
|
#endif
|
|
|
|
tty->print_cr("\"%s\"...", cmd);
|
|
|
|
|
2015-05-12 20:55:40 -04:00
|
|
|
if (os::fork_and_exec(cmd) < 0) {
|
2016-03-12 08:35:05 +01:00
|
|
|
tty->print_cr("os::fork_and_exec failed: %s (%s=%d)",
|
|
|
|
os::strerror(errno), os::errno_name(errno), errno);
|
2015-05-12 20:55:40 -04:00
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-29 11:02:08 +02:00
|
|
|
void VMError::report_java_out_of_memory(const char* message) {
|
2007-12-01 00:00:00 +00:00
|
|
|
if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
|
|
|
|
MutexLocker ml(Heap_lock);
|
2015-09-29 11:02:08 +02:00
|
|
|
VM_ReportJavaOutOfMemory op(message);
|
2007-12-01 00:00:00 +00:00
|
|
|
VMThread::execute(&op);
|
|
|
|
}
|
|
|
|
}
|
2015-11-25 16:33:28 +01:00
|
|
|
|
|
|
|
void VMError::show_message_box(char *buf, int buflen) {
|
|
|
|
bool yes;
|
|
|
|
do {
|
|
|
|
error_string(buf, buflen);
|
|
|
|
yes = os::start_debugging(buf,buflen);
|
|
|
|
} while (yes);
|
|
|
|
}
|