< prev index next >

src/share/vm/utilities/vmError.hpp

Print this page
rev 12508 : 8166944: Hanging Error Reporting steps may lead to torn error logs.
Reviewed-by: cjplummer, dholmes
Summary: Interupt error reporting if reporting steps hang to enable subsequent reporting steps to run.
   1 /*
   2  * Copyright (c) 2003, 2015, 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  *


  57 
  58   // used by reporting about OOM
  59   static size_t      _size;
  60 
  61   // used by fatal error handler
  62   static int         _current_step;
  63   static const char* _current_step_info;
  64 
  65   // Thread id of the first error. We must be able to handle native thread,
  66   // so use thread id instead of Thread* to identify thread.
  67   static volatile intptr_t first_error_tid;
  68 
  69   // Core dump status, false if we have been unable to write a core/minidump for some reason
  70   static bool coredump_status;
  71 
  72   // When coredump_status is set to true this will contain the name/path to the core/minidump,
  73   // if coredump_status if false, this will (hopefully) contain a useful error explaining why
  74   // no core/minidump has been written to disk
  75   static char coredump_message[O_BUFLEN];
  76 










  77 
  78   // set signal handlers on Solaris/Linux or the default exception filter
  79   // on Windows, to handle recursive crashes.
  80   static void reset_signal_handlers();
  81 
  82   // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
  83   static void show_message_box(char* buf, int buflen);
  84 
  85   // generate an error report
  86   static void report(outputStream* st, bool verbose);
  87 
  88   // generate a stack trace
  89   static void print_stack_trace(outputStream* st, JavaThread* jt,
  90                                 char* buf, int buflen, bool verbose = false);
  91 
  92   static bool should_report_bug(unsigned int id) {
  93     return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
  94   }
  95 
  96   // Write a hint to the stream in case siginfo relates to a segv/bus error
  97   // and the offending address points into CDS store.
  98   static void check_failing_cds_access(outputStream* st, const void* siginfo);
  99 
 100   static void report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo,
 101                              void* context, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(6, 7);
 102   static void report_and_die(const char* message, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(2, 3);
 103 
 104   static fdStream out;
 105   static fdStream log; // error log used by VMError::report_and_die()
 106 














 107 public:
 108 
 109   // return a string to describe the error
 110   static char* error_string(char* buf, int buflen);
 111 
 112   // Record status of core/minidump
 113   static void record_coredump_status(const char* message, bool status);
 114 
 115   // support for VM.info diagnostic command
 116   static void print_vm_info(outputStream* st);
 117 
 118   // main error reporting function
 119   static void report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
 120                              Thread* thread, address pc, void* siginfo, void* context,
 121                              const char* filename, int lineno, size_t size) ATTRIBUTE_PRINTF(3, 0);
 122 
 123   static void report_and_die(Thread* thread, unsigned int sig, address pc,
 124                              void* siginfo, void* context);
 125 
 126   static void report_and_die(Thread* thread,const char* filename, int lineno, const char* message,


 130                              VMErrorType vm_err_type, const char* detail_fmt,
 131                              va_list detail_args) ATTRIBUTE_PRINTF(6, 0);
 132 
 133   static void report_and_die(const char* message);
 134 
 135   // reporting OutOfMemoryError
 136   static void report_java_out_of_memory(const char* message);
 137 
 138   // returns original flags for signal, if it was resetted, or -1 if
 139   // signal was not changed by error reporter
 140   static int get_resetted_sigflags(int sig);
 141 
 142   // returns original handler for signal, if it was resetted, or NULL if
 143   // signal was not changed by error reporter
 144   static address get_resetted_sighandler(int sig);
 145 
 146   // check to see if fatal error reporting is in progress
 147   static bool fatal_error_in_progress() { return first_error_tid != -1; }
 148 
 149   static intptr_t get_first_error_tid() { return first_error_tid; }





 150 };
 151 
 152 #endif // SHARE_VM_UTILITIES_VMERROR_HPP
   1 /*
   2  * Copyright (c) 2003, 2017, 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  *


  57 
  58   // used by reporting about OOM
  59   static size_t      _size;
  60 
  61   // used by fatal error handler
  62   static int         _current_step;
  63   static const char* _current_step_info;
  64 
  65   // Thread id of the first error. We must be able to handle native thread,
  66   // so use thread id instead of Thread* to identify thread.
  67   static volatile intptr_t first_error_tid;
  68 
  69   // Core dump status, false if we have been unable to write a core/minidump for some reason
  70   static bool coredump_status;
  71 
  72   // When coredump_status is set to true this will contain the name/path to the core/minidump,
  73   // if coredump_status if false, this will (hopefully) contain a useful error explaining why
  74   // no core/minidump has been written to disk
  75   static char coredump_message[O_BUFLEN];
  76 
  77   // Timeout handling:
  78   // Timestamp at which error reporting started; -1 if no error reporting in progress.
  79   static volatile jlong _reporting_start_time;
  80   // Whether or not error reporting did timeout.
  81   static volatile bool _reporting_did_timeout;
  82   // Timestamp at which the last error reporting step started; -1 if no error reporting
  83   //   in progress.
  84   static volatile jlong _step_start_time;
  85   // Whether or not the last error reporting step did timeout.
  86   static volatile bool _step_did_timeout;
  87 
  88   // set signal handlers on Solaris/Linux or the default exception filter
  89   // on Windows, to handle recursive crashes.
  90   static void reset_signal_handlers();
  91 
  92   // handle -XX:+ShowMessageBoxOnError. buf is used to format the message string
  93   static void show_message_box(char* buf, int buflen);
  94 
  95   // generate an error report
  96   static void report(outputStream* st, bool verbose);
  97 
  98   // generate a stack trace
  99   static void print_stack_trace(outputStream* st, JavaThread* jt,
 100                                 char* buf, int buflen, bool verbose = false);
 101 
 102   static bool should_report_bug(unsigned int id) {
 103     return (id != OOM_MALLOC_ERROR) && (id != OOM_MMAP_ERROR);
 104   }
 105 
 106   // Write a hint to the stream in case siginfo relates to a segv/bus error
 107   // and the offending address points into CDS store.
 108   static void check_failing_cds_access(outputStream* st, const void* siginfo);
 109 
 110   static void report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo,
 111                              void* context, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(6, 7);
 112   static void report_and_die(const char* message, const char* detail_fmt, ...) ATTRIBUTE_PRINTF(2, 3);
 113 
 114   static fdStream out;
 115   static fdStream log; // error log used by VMError::report_and_die()
 116 
 117   // Timeout handling.
 118   // Hook functions for platform dependend functionality:
 119   static void reporting_started();
 120   static void interrupt_reporting_thread();
 121 
 122   // Helper function to get the current timestamp.
 123   static jlong get_current_timestamp();
 124 
 125   // Accessors to get/set the start times for step and total timeout.
 126   static void record_reporting_start_time();
 127   static jlong get_reporting_start_time();
 128   static void record_step_start_time();
 129   static jlong get_step_start_time();
 130 
 131 public:
 132 
 133   // return a string to describe the error
 134   static char* error_string(char* buf, int buflen);
 135 
 136   // Record status of core/minidump
 137   static void record_coredump_status(const char* message, bool status);
 138 
 139   // support for VM.info diagnostic command
 140   static void print_vm_info(outputStream* st);
 141 
 142   // main error reporting function
 143   static void report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
 144                              Thread* thread, address pc, void* siginfo, void* context,
 145                              const char* filename, int lineno, size_t size) ATTRIBUTE_PRINTF(3, 0);
 146 
 147   static void report_and_die(Thread* thread, unsigned int sig, address pc,
 148                              void* siginfo, void* context);
 149 
 150   static void report_and_die(Thread* thread,const char* filename, int lineno, const char* message,


 154                              VMErrorType vm_err_type, const char* detail_fmt,
 155                              va_list detail_args) ATTRIBUTE_PRINTF(6, 0);
 156 
 157   static void report_and_die(const char* message);
 158 
 159   // reporting OutOfMemoryError
 160   static void report_java_out_of_memory(const char* message);
 161 
 162   // returns original flags for signal, if it was resetted, or -1 if
 163   // signal was not changed by error reporter
 164   static int get_resetted_sigflags(int sig);
 165 
 166   // returns original handler for signal, if it was resetted, or NULL if
 167   // signal was not changed by error reporter
 168   static address get_resetted_sighandler(int sig);
 169 
 170   // check to see if fatal error reporting is in progress
 171   static bool fatal_error_in_progress() { return first_error_tid != -1; }
 172 
 173   static intptr_t get_first_error_tid() { return first_error_tid; }
 174 
 175   // Called by the WatcherThread to check if error reporting has timed-out.
 176   //  Returns true if error reporting has not completed within the ErrorLogTimeout limit.
 177   static bool check_timeout();
 178 
 179 };
 180 
 181 #endif // SHARE_VM_UTILITIES_VMERROR_HPP
< prev index next >