197 }
198
199
200 static void print_bug_submit_message(outputStream *out, Thread *thread) {
201 if (out == NULL) return;
202 out->print_raw_cr("# If you would like to submit a bug report, please visit:");
203 out->print_raw ("# ");
204 out->print_raw_cr(Arguments::java_vendor_url_bug());
205 // If the crash is in native code, encourage user to submit a bug to the
206 // provider of that code.
207 if (thread && thread->is_Java_thread() &&
208 !thread->is_hidden_from_external_view()) {
209 JavaThread* jt = (JavaThread*)thread;
210 if (jt->thread_state() == _thread_in_native) {
211 out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug.");
212 }
213 }
214 out->print_raw_cr("#");
215 }
216
217 bool VMError::coredump_status;
218 char VMError::coredump_message[O_BUFLEN];
219
220 void VMError::report_coredump_status(const char* message, bool status) {
221 coredump_status = status;
222 strncpy(coredump_message, message, sizeof(coredump_message));
223 coredump_message[sizeof(coredump_message)-1] = 0;
224 }
225
226
227 // Return a string to describe the error
228 char* VMError::error_string(char* buf, int buflen) {
229 char signame_buf[64];
230 const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf));
231
232 if (signame) {
233 jio_snprintf(buf, buflen,
234 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT,
235 signame, _id, _pc,
236 os::current_process_id(), os::current_thread_id());
237 } else if (_filename != NULL && _lineno > 0) {
488 Abstract_VM_Version::vm_name(),
489 Abstract_VM_Version::vm_release(),
490 Abstract_VM_Version::vm_info_string(),
491 Abstract_VM_Version::vm_platform_string(),
492 UseCompressedOops ? "compressed oops" : ""
493 );
494
495 STEP(60, "(printing problematic frame)")
496
497 // Print current frame if we have a context (i.e. it's a crash)
498 if (_context) {
499 st->print_cr("# Problematic frame:");
500 st->print("# ");
501 frame fr = os::fetch_frame_from_context(_context);
502 fr.print_on_error(st, buf, sizeof(buf));
503 st->cr();
504 st->print_cr("#");
505 }
506 STEP(63, "(printing core file information)")
507 st->print("# ");
508 if (coredump_status) {
509 st->print("Core dump written. Default location: %s", coredump_message);
510 } else {
511 st->print("Failed to write core dump. %s", coredump_message);
512 }
513 st->cr();
514 st->print_cr("#");
515
516 STEP(65, "(printing bug submit message)")
517
518 if (should_report_bug(_id) && _verbose) {
519 print_bug_submit_message(st, _thread);
520 }
521
522 STEP(70, "(printing thread)" )
523
524 if (_verbose) {
525 st->cr();
526 st->print_cr("--------------- T H R E A D ---------------");
527 st->cr();
528 }
529
530 STEP(80, "(printing current thread)" )
531
532 // current thread
881 }
882 }
883
884 return fd;
885 }
886
887 void VMError::report_and_die() {
888 // Don't allocate large buffer on stack
889 static char buffer[O_BUFLEN];
890
891 // How many errors occurred in error handler when reporting first_error.
892 static int recursive_error_count;
893
894 // We will first print a brief message to standard out (verbose = false),
895 // then save detailed information in log file (verbose = true).
896 static bool out_done = false; // done printing to standard out
897 static bool log_done = false; // done saving error log
898 static bool transmit_report_done = false; // done error reporting
899
900 if (SuppressFatalErrorMessage) {
901 os::abort();
902 }
903 jlong mytid = os::current_thread_id();
904 if (first_error == NULL &&
905 Atomic::cmpxchg_ptr(this, &first_error, NULL) == NULL) {
906
907 // first time
908 first_error_tid = mytid;
909 set_error_reported();
910
911 if (ShowMessageBoxOnError || PauseAtExit) {
912 show_message_box(buffer, sizeof(buffer));
913
914 // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
915 // WatcherThread can kill JVM if the error handler hangs.
916 ShowMessageBoxOnError = false;
917 }
918
919 // Write a minidump on Windows, check core dump limits on Linux/Solaris
920 os::check_or_create_dump(_siginfo, _context, buffer, sizeof(buffer));
921
922 // reset signal handlers or exception filter; make sure recursive crashes
923 // are handled properly.
924 reset_signal_handlers();
925
926 } else {
927 // If UseOsErrorReporting we call this for each level of the call stack
928 // while searching for the exception handler. Only the first level needs
929 // to be reported.
930 if (UseOSErrorReporting && log_done) return;
931
932 // This is not the first error, see if it happened in a different thread
933 // or in the same thread during error reporting.
934 if (first_error_tid != mytid) {
935 char msgbuf[64];
936 jio_snprintf(msgbuf, sizeof(msgbuf),
937 "[thread " INT64_FORMAT " also had an error]",
938 mytid);
939 out.print_raw_cr(msgbuf);
940
1071 out.print_raw_cr(strerror(os::get_last_error()));
1072 }
1073 }
1074 }
1075 }
1076
1077 static bool skip_bug_url = !should_report_bug(first_error->_id);
1078 if (!skip_bug_url) {
1079 skip_bug_url = true;
1080
1081 out.print_raw_cr("#");
1082 print_bug_submit_message(&out, _thread);
1083 }
1084
1085 if (!UseOSErrorReporting) {
1086 // os::abort() will call abort hooks, try it first.
1087 static bool skip_os_abort = false;
1088 if (!skip_os_abort) {
1089 skip_os_abort = true;
1090 bool dump_core = should_report_bug(first_error->_id);
1091 os::abort(dump_core);
1092 }
1093
1094 // if os::abort() doesn't abort, try os::die();
1095 os::die();
1096 }
1097 }
1098
1099 /*
1100 * OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this
1101 * ensures utilities such as jmap can observe the process is a consistent state.
1102 */
1103 class VM_ReportJavaOutOfMemory : public VM_Operation {
1104 private:
1105 VMError *_err;
1106 public:
1107 VM_ReportJavaOutOfMemory(VMError *err) { _err = err; }
1108 VMOp_Type type() const { return VMOp_ReportJavaOutOfMemory; }
1109 void doit();
1110 };
1111
|
197 }
198
199
200 static void print_bug_submit_message(outputStream *out, Thread *thread) {
201 if (out == NULL) return;
202 out->print_raw_cr("# If you would like to submit a bug report, please visit:");
203 out->print_raw ("# ");
204 out->print_raw_cr(Arguments::java_vendor_url_bug());
205 // If the crash is in native code, encourage user to submit a bug to the
206 // provider of that code.
207 if (thread && thread->is_Java_thread() &&
208 !thread->is_hidden_from_external_view()) {
209 JavaThread* jt = (JavaThread*)thread;
210 if (jt->thread_state() == _thread_in_native) {
211 out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug.");
212 }
213 }
214 out->print_raw_cr("#");
215 }
216
217 bool VMError::coredump_status = true; // presume we can dump core file first
218 char VMError::coredump_message[O_BUFLEN];
219
220 void VMError::report_coredump_status(const char* message, bool status) {
221 coredump_status = status;
222 strncpy(coredump_message, message, sizeof(coredump_message));
223 coredump_message[sizeof(coredump_message)-1] = 0;
224 }
225
226
227 // Return a string to describe the error
228 char* VMError::error_string(char* buf, int buflen) {
229 char signame_buf[64];
230 const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf));
231
232 if (signame) {
233 jio_snprintf(buf, buflen,
234 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT,
235 signame, _id, _pc,
236 os::current_process_id(), os::current_thread_id());
237 } else if (_filename != NULL && _lineno > 0) {
488 Abstract_VM_Version::vm_name(),
489 Abstract_VM_Version::vm_release(),
490 Abstract_VM_Version::vm_info_string(),
491 Abstract_VM_Version::vm_platform_string(),
492 UseCompressedOops ? "compressed oops" : ""
493 );
494
495 STEP(60, "(printing problematic frame)")
496
497 // Print current frame if we have a context (i.e. it's a crash)
498 if (_context) {
499 st->print_cr("# Problematic frame:");
500 st->print("# ");
501 frame fr = os::fetch_frame_from_context(_context);
502 fr.print_on_error(st, buf, sizeof(buf));
503 st->cr();
504 st->print_cr("#");
505 }
506 STEP(63, "(printing core file information)")
507 st->print("# ");
508 if (CreateCoredumpOnCrash) {
509 if (coredump_status) {
510 st->print("Core dump written. Default location: %s", coredump_message);
511 } else {
512 st->print("Failed to write core dump. %s", coredump_message);
513 }
514 } else {
515 st->print("CreateCoredumpOnCrash turned off, no core file dumped");
516 }
517 st->cr();
518 st->print_cr("#");
519
520 STEP(65, "(printing bug submit message)")
521
522 if (should_report_bug(_id) && _verbose) {
523 print_bug_submit_message(st, _thread);
524 }
525
526 STEP(70, "(printing thread)" )
527
528 if (_verbose) {
529 st->cr();
530 st->print_cr("--------------- T H R E A D ---------------");
531 st->cr();
532 }
533
534 STEP(80, "(printing current thread)" )
535
536 // current thread
885 }
886 }
887
888 return fd;
889 }
890
891 void VMError::report_and_die() {
892 // Don't allocate large buffer on stack
893 static char buffer[O_BUFLEN];
894
895 // How many errors occurred in error handler when reporting first_error.
896 static int recursive_error_count;
897
898 // We will first print a brief message to standard out (verbose = false),
899 // then save detailed information in log file (verbose = true).
900 static bool out_done = false; // done printing to standard out
901 static bool log_done = false; // done saving error log
902 static bool transmit_report_done = false; // done error reporting
903
904 if (SuppressFatalErrorMessage) {
905 os::abort(CreateCoredumpOnCrash);
906 }
907 jlong mytid = os::current_thread_id();
908 if (first_error == NULL &&
909 Atomic::cmpxchg_ptr(this, &first_error, NULL) == NULL) {
910
911 // first time
912 first_error_tid = mytid;
913 set_error_reported();
914
915 if (ShowMessageBoxOnError || PauseAtExit) {
916 show_message_box(buffer, sizeof(buffer));
917
918 // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
919 // WatcherThread can kill JVM if the error handler hangs.
920 ShowMessageBoxOnError = false;
921 }
922
923 // check core dump limits on Linux/Solaris, nothing on Windows
924 os::check_create_dump_limit(_siginfo, _context, buffer, sizeof(buffer));
925
926 // reset signal handlers or exception filter; make sure recursive crashes
927 // are handled properly.
928 reset_signal_handlers();
929
930 } else {
931 // If UseOsErrorReporting we call this for each level of the call stack
932 // while searching for the exception handler. Only the first level needs
933 // to be reported.
934 if (UseOSErrorReporting && log_done) return;
935
936 // This is not the first error, see if it happened in a different thread
937 // or in the same thread during error reporting.
938 if (first_error_tid != mytid) {
939 char msgbuf[64];
940 jio_snprintf(msgbuf, sizeof(msgbuf),
941 "[thread " INT64_FORMAT " also had an error]",
942 mytid);
943 out.print_raw_cr(msgbuf);
944
1075 out.print_raw_cr(strerror(os::get_last_error()));
1076 }
1077 }
1078 }
1079 }
1080
1081 static bool skip_bug_url = !should_report_bug(first_error->_id);
1082 if (!skip_bug_url) {
1083 skip_bug_url = true;
1084
1085 out.print_raw_cr("#");
1086 print_bug_submit_message(&out, _thread);
1087 }
1088
1089 if (!UseOSErrorReporting) {
1090 // os::abort() will call abort hooks, try it first.
1091 static bool skip_os_abort = false;
1092 if (!skip_os_abort) {
1093 skip_os_abort = true;
1094 bool dump_core = should_report_bug(first_error->_id);
1095 os::abort(dump_core && CreateCoredumpOnCrash, _siginfo, _context);
1096 }
1097
1098 // if os::abort() doesn't abort, try os::die();
1099 os::die();
1100 }
1101 }
1102
1103 /*
1104 * OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this
1105 * ensures utilities such as jmap can observe the process is a consistent state.
1106 */
1107 class VM_ReportJavaOutOfMemory : public VM_Operation {
1108 private:
1109 VMError *_err;
1110 public:
1111 VM_ReportJavaOutOfMemory(VMError *err) { _err = err; }
1112 VMOp_Type type() const { return VMOp_ReportJavaOutOfMemory; }
1113 void doit();
1114 };
1115
|