annotate hotspot/src/share/vm/utilities/vmError.hpp @ 46545:b970b6e40209

8181450: assert in BasicHashtable::verify_table Summary: remove assert as it has small probability of happening and added logging Reviewed-by: kbarrett, sspitsyn
author coleenp
date Fri, 16 Jun 2017 09:13:56 -0400
parents aa3dbc37ede9
children 388aa8d67c80
rev   line source
duke@1 1 /*
stuefe@46284 2 * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #ifndef SHARE_VM_UTILITIES_VMERROR_HPP
stefank@7397 26 #define SHARE_VM_UTILITIES_VMERROR_HPP
stefank@7397 27
stefank@7397 28 #include "utilities/globalDefinitions.hpp"
stefank@7397 29
zgu@11761 30 class Decoder;
duke@1 31 class VM_ReportJavaOutOfMemory;
duke@1 32
david@33105 33 class VMError : public AllStatic {
duke@1 34 friend class VM_ReportJavaOutOfMemory;
zgu@11761 35 friend class Decoder;
ysuenaga@38266 36 friend class VMStructs;
duke@1 37
david@33105 38 static int _id; // Solaris/Linux signals: 0 - SIGRTMAX
david@33105 39 // Windows exceptions: 0xCxxxxxxx system errors
david@33105 40 // 0x8xxxxxxx system warnings
duke@1 41
david@33105 42 static const char* _message;
david@33105 43 static char _detail_msg[1024];
duke@1 44
david@33105 45 static Thread* _thread; // NULL if it's native thread
duke@1 46
duke@1 47 // additional info for crashes
david@33105 48 static address _pc; // faulting PC
david@33105 49 static void* _siginfo; // ExceptionRecord on Windows,
david@33105 50 // siginfo_t on Solaris/Linux
david@33105 51 static void* _context; // ContextRecord on Windows,
david@33105 52 // ucontext_t on Solaris/Linux
duke@1 53
duke@1 54 // additional info for VM internal errors
david@33105 55 static const char* _filename;
david@33105 56 static int _lineno;
david@33105 57
david@33105 58 // used by reporting about OOM
david@33105 59 static size_t _size;
duke@1 60
duke@1 61 // used by fatal error handler
david@33105 62 static int _current_step;
david@33105 63 static const char* _current_step_info;
david@33105 64
david@33105 65 // Thread id of the first error. We must be able to handle native thread,
bobv@6176 66 // so use thread id instead of Thread* to identify thread.
david@33131 67 static volatile intptr_t first_error_tid;
duke@1 68
ctornqvi@8119 69 // Core dump status, false if we have been unable to write a core/minidump for some reason
ctornqvi@8119 70 static bool coredump_status;
ctornqvi@8119 71
ctornqvi@8119 72 // When coredump_status is set to true this will contain the name/path to the core/minidump,
ctornqvi@8119 73 // if coredump_status if false, this will (hopefully) contain a useful error explaining why
ctornqvi@8119 74 // no core/minidump has been written to disk
ctornqvi@8119 75 static char coredump_message[O_BUFLEN];
ctornqvi@8119 76
stuefe@46284 77 // Timeout handling:
stuefe@46284 78 // Timestamp at which error reporting started; -1 if no error reporting in progress.
stuefe@46284 79 static volatile jlong _reporting_start_time;
stuefe@46284 80 // Whether or not error reporting did timeout.
stuefe@46284 81 static volatile bool _reporting_did_timeout;
stuefe@46284 82 // Timestamp at which the last error reporting step started; -1 if no error reporting
stuefe@46284 83 // in progress.
stuefe@46284 84 static volatile jlong _step_start_time;
stuefe@46284 85 // Whether or not the last error reporting step did timeout.
stuefe@46284 86 static volatile bool _step_did_timeout;
duke@1 87
duke@1 88 // set signal handlers on Solaris/Linux or the default exception filter
duke@1 89 // on Windows, to handle recursive crashes.
david@33105 90 static void reset_signal_handlers();
duke@1 91
duke@1 92 // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
david@33105 93 static void show_message_box(char* buf, int buflen);
duke@1 94
duke@1 95 // generate an error report
david@33105 96 static void report(outputStream* st, bool verbose);
duke@1 97
twisti@5340 98 // generate a stack trace
twisti@5340 99 static void print_stack_trace(outputStream* st, JavaThread* jt,
twisti@5340 100 char* buf, int buflen, bool verbose = false);
twisti@5340 101
david@33105 102 static bool should_report_bug(unsigned int id) {
ccheung@17087 103 return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
ccheung@17087 104 }
duke@1 105
stuefe@35176 106 // Write a hint to the stream in case siginfo relates to a segv/bus error
stuefe@35176 107 // and the offending address points into CDS store.
stuefe@35176 108 static void check_failing_cds_access(outputStream* st, const void* siginfo);
stuefe@35176 109
david@33105 110 static void report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo,
david@33105 111 void* context, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(6, 7);
david@33105 112 static void report_and_die(const char* message, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(2, 3);
david@33105 113
fparain@18487 114 static fdStream out;
fparain@18487 115 static fdStream log; // error log used by VMError::report_and_die()
fparain@18487 116
stuefe@46284 117 // Timeout handling.
stuefe@46284 118 // Hook functions for platform dependend functionality:
stuefe@46284 119 static void reporting_started();
stuefe@46284 120 static void interrupt_reporting_thread();
stuefe@46284 121
stuefe@46284 122 // Helper function to get the current timestamp.
stuefe@46284 123 static jlong get_current_timestamp();
stuefe@46284 124
stuefe@46284 125 // Accessors to get/set the start times for step and total timeout.
stuefe@46284 126 static void record_reporting_start_time();
stuefe@46284 127 static jlong get_reporting_start_time();
stuefe@46284 128 static void record_step_start_time();
stuefe@46284 129 static jlong get_step_start_time();
stuefe@46284 130
duke@1 131 public:
ccheung@17087 132
duke@1 133 // return a string to describe the error
david@33105 134 static char* error_string(char* buf, int buflen);
duke@1 135
minqi@30240 136 // Record status of core/minidump
minqi@30240 137 static void record_coredump_status(const char* message, bool status);
ctornqvi@8119 138
coleenp@34139 139 // support for VM.info diagnostic command
coleenp@34139 140 static void print_vm_info(outputStream* st);
coleenp@34139 141
duke@1 142 // main error reporting function
david@33105 143 static void report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
david@33105 144 Thread* thread, address pc, void* siginfo, void* context,
david@33105 145 const char* filename, int lineno, size_t size) ATTRIBUTE_PRINTF(3, 0);
david@33105 146
david@33105 147 static void report_and_die(Thread* thread, unsigned int sig, address pc,
david@33105 148 void* siginfo, void* context);
david@33105 149
david@33105 150 static void report_and_die(Thread* thread,const char* filename, int lineno, const char* message,
david@33105 151 const char* detail_fmt, va_list detail_args) ATTRIBUTE_PRINTF(5, 0);
david@33105 152
david@33105 153 static void report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
david@33105 154 VMErrorType vm_err_type, const char* detail_fmt,
david@33105 155 va_list detail_args) ATTRIBUTE_PRINTF(6, 0);
david@33105 156
david@33105 157 static void report_and_die(const char* message);
duke@1 158
duke@1 159 // reporting OutOfMemoryError
david@33105 160 static void report_java_out_of_memory(const char* message);
duke@1 161
duke@1 162 // returns original flags for signal, if it was resetted, or -1 if
duke@1 163 // signal was not changed by error reporter
duke@1 164 static int get_resetted_sigflags(int sig);
duke@1 165
duke@1 166 // returns original handler for signal, if it was resetted, or NULL if
duke@1 167 // signal was not changed by error reporter
duke@1 168 static address get_resetted_sighandler(int sig);
bobv@6176 169
bobv@6176 170 // check to see if fatal error reporting is in progress
david@33105 171 static bool fatal_error_in_progress() { return first_error_tid != -1; }
iklam@19952 172
david@33131 173 static intptr_t get_first_error_tid() { return first_error_tid; }
stuefe@46284 174
stuefe@46284 175 // Called by the WatcherThread to check if error reporting has timed-out.
stuefe@46284 176 // Returns true if error reporting has not completed within the ErrorLogTimeout limit.
stuefe@46284 177 static bool check_timeout();
stuefe@46284 178
duke@1 179 };
stefank@7397 180
stefank@7397 181 #endif // SHARE_VM_UTILITIES_VMERROR_HPP