src/share/vm/utilities/vmError.cpp

Print this page




 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) {


 508                    Abstract_VM_Version::vm_name(),
 509                    Abstract_VM_Version::vm_release(),
 510                    Abstract_VM_Version::vm_info_string(),
 511                    Abstract_VM_Version::vm_platform_string(),
 512                    UseCompressedOops ? "compressed oops" : ""
 513                  );
 514 
 515   STEP(60, "(printing problematic frame)")
 516 
 517      // Print current frame if we have a context (i.e. it's a crash)
 518      if (_context) {
 519        st->print_cr("# Problematic frame:");
 520        st->print("# ");
 521        frame fr = os::fetch_frame_from_context(_context);
 522        fr.print_on_error(st, buf, sizeof(buf));
 523        st->cr();
 524        st->print_cr("#");
 525      }
 526   STEP(63, "(printing core file information)")
 527     st->print("# ");

 528     if (coredump_status) {
 529       st->print("Core dump written. Default location: %s", coredump_message);
 530     } else {
 531       st->print("Failed to write core dump. %s", coredump_message);
 532     }



 533     st->cr();
 534     st->print_cr("#");
 535 
 536   STEP(65, "(printing bug submit message)")
 537 
 538      if (should_report_bug(_id) && _verbose) {
 539        print_bug_submit_message(st, _thread);
 540      }
 541 
 542   STEP(70, "(printing thread)" )
 543 
 544      if (_verbose) {
 545        st->cr();
 546        st->print_cr("---------------  T H R E A D  ---------------");
 547        st->cr();
 548      }
 549 
 550   STEP(80, "(printing current thread)" )
 551 
 552      // current thread


 901      }
 902    }
 903 
 904   return fd;
 905 }
 906 
 907 void VMError::report_and_die() {
 908   // Don't allocate large buffer on stack
 909   static char buffer[O_BUFLEN];
 910 
 911   // How many errors occurred in error handler when reporting first_error.
 912   static int recursive_error_count;
 913 
 914   // We will first print a brief message to standard out (verbose = false),
 915   // then save detailed information in log file (verbose = true).
 916   static bool out_done = false;         // done printing to standard out
 917   static bool log_done = false;         // done saving error log
 918   static bool transmit_report_done = false; // done error reporting
 919 
 920   if (SuppressFatalErrorMessage) {
 921       os::abort();
 922   }
 923   jlong mytid = os::current_thread_id();
 924   if (first_error == NULL &&
 925       Atomic::cmpxchg_ptr(this, &first_error, NULL) == NULL) {
 926 
 927     // first time
 928     first_error_tid = mytid;
 929     set_error_reported();
 930 
 931     if (ShowMessageBoxOnError || PauseAtExit) {
 932       show_message_box(buffer, sizeof(buffer));
 933 
 934       // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
 935       // WatcherThread can kill JVM if the error handler hangs.
 936       ShowMessageBoxOnError = false;
 937     }
 938 
 939     // Write a minidump on Windows, check core dump limits on Linux/Solaris
 940     os::check_or_create_dump(_siginfo, _context, buffer, sizeof(buffer));
 941 
 942     // reset signal handlers or exception filter; make sure recursive crashes
 943     // are handled properly.
 944     reset_signal_handlers();
 945 
 946   } else {
 947     // If UseOsErrorReporting we call this for each level of the call stack
 948     // while searching for the exception handler.  Only the first level needs
 949     // to be reported.
 950     if (UseOSErrorReporting && log_done) return;
 951 
 952     // This is not the first error, see if it happened in a different thread
 953     // or in the same thread during error reporting.
 954     if (first_error_tid != mytid) {
 955       char msgbuf[64];
 956       jio_snprintf(msgbuf, sizeof(msgbuf),
 957                    "[thread " INT64_FORMAT " also had an error]",
 958                    mytid);
 959       out.print_raw_cr(msgbuf);
 960 


1091           out.print_raw_cr(strerror(os::get_last_error()));
1092         }
1093       }
1094     }
1095   }
1096 
1097   static bool skip_bug_url = !should_report_bug(first_error->_id);
1098   if (!skip_bug_url) {
1099     skip_bug_url = true;
1100 
1101     out.print_raw_cr("#");
1102     print_bug_submit_message(&out, _thread);
1103   }
1104 
1105   if (!UseOSErrorReporting) {
1106     // os::abort() will call abort hooks, try it first.
1107     static bool skip_os_abort = false;
1108     if (!skip_os_abort) {
1109       skip_os_abort = true;
1110       bool dump_core = should_report_bug(first_error->_id);
1111       os::abort(dump_core);
1112     }
1113 
1114     // if os::abort() doesn't abort, try os::die();
1115     os::die();
1116   }
1117 }
1118 
1119 /*
1120  * OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this
1121  * ensures utilities such as jmap can observe the process is a consistent state.
1122  */
1123 class VM_ReportJavaOutOfMemory : public VM_Operation {
1124  private:
1125   VMError *_err;
1126  public:
1127   VM_ReportJavaOutOfMemory(VMError *err) { _err = err; }
1128   VMOp_Type type() const                 { return VMOp_ReportJavaOutOfMemory; }
1129   void doit();
1130 };
1131 




 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) {


 508                    Abstract_VM_Version::vm_name(),
 509                    Abstract_VM_Version::vm_release(),
 510                    Abstract_VM_Version::vm_info_string(),
 511                    Abstract_VM_Version::vm_platform_string(),
 512                    UseCompressedOops ? "compressed oops" : ""
 513                  );
 514 
 515   STEP(60, "(printing problematic frame)")
 516 
 517      // Print current frame if we have a context (i.e. it's a crash)
 518      if (_context) {
 519        st->print_cr("# Problematic frame:");
 520        st->print("# ");
 521        frame fr = os::fetch_frame_from_context(_context);
 522        fr.print_on_error(st, buf, sizeof(buf));
 523        st->cr();
 524        st->print_cr("#");
 525      }
 526   STEP(63, "(printing core file information)")
 527     st->print("# ");
 528     if (CreateCoredumpOnCrash) {
 529       if (coredump_status) {
 530         st->print("Core dump written. Default location: %s", coredump_message);
 531       } else {
 532         st->print("Failed to write core dump. %s", coredump_message);
 533       }
 534     } else {
 535       st->print("CreateCoredumpOnCrash turned off, no core file dumped");
 536     }
 537     st->cr();
 538     st->print_cr("#");
 539 
 540   STEP(65, "(printing bug submit message)")
 541 
 542      if (should_report_bug(_id) && _verbose) {
 543        print_bug_submit_message(st, _thread);
 544      }
 545 
 546   STEP(70, "(printing thread)" )
 547 
 548      if (_verbose) {
 549        st->cr();
 550        st->print_cr("---------------  T H R E A D  ---------------");
 551        st->cr();
 552      }
 553 
 554   STEP(80, "(printing current thread)" )
 555 
 556      // current thread


 905      }
 906    }
 907 
 908   return fd;
 909 }
 910 
 911 void VMError::report_and_die() {
 912   // Don't allocate large buffer on stack
 913   static char buffer[O_BUFLEN];
 914 
 915   // How many errors occurred in error handler when reporting first_error.
 916   static int recursive_error_count;
 917 
 918   // We will first print a brief message to standard out (verbose = false),
 919   // then save detailed information in log file (verbose = true).
 920   static bool out_done = false;         // done printing to standard out
 921   static bool log_done = false;         // done saving error log
 922   static bool transmit_report_done = false; // done error reporting
 923 
 924   if (SuppressFatalErrorMessage) {
 925       os::abort(CreateCoredumpOnCrash);
 926   }
 927   jlong mytid = os::current_thread_id();
 928   if (first_error == NULL &&
 929       Atomic::cmpxchg_ptr(this, &first_error, NULL) == NULL) {
 930 
 931     // first time
 932     first_error_tid = mytid;
 933     set_error_reported();
 934 
 935     if (ShowMessageBoxOnError || PauseAtExit) {
 936       show_message_box(buffer, sizeof(buffer));
 937 
 938       // User has asked JVM to abort. Reset ShowMessageBoxOnError so the
 939       // WatcherThread can kill JVM if the error handler hangs.
 940       ShowMessageBoxOnError = false;
 941     }
 942 
 943     // check core dump limits on Linux/Solaris, nothing on Windows
 944     os::check_dump_limit(buffer, sizeof(buffer));
 945 
 946     // reset signal handlers or exception filter; make sure recursive crashes
 947     // are handled properly.
 948     reset_signal_handlers();
 949 
 950   } else {
 951     // If UseOsErrorReporting we call this for each level of the call stack
 952     // while searching for the exception handler.  Only the first level needs
 953     // to be reported.
 954     if (UseOSErrorReporting && log_done) return;
 955 
 956     // This is not the first error, see if it happened in a different thread
 957     // or in the same thread during error reporting.
 958     if (first_error_tid != mytid) {
 959       char msgbuf[64];
 960       jio_snprintf(msgbuf, sizeof(msgbuf),
 961                    "[thread " INT64_FORMAT " also had an error]",
 962                    mytid);
 963       out.print_raw_cr(msgbuf);
 964 


1095           out.print_raw_cr(strerror(os::get_last_error()));
1096         }
1097       }
1098     }
1099   }
1100 
1101   static bool skip_bug_url = !should_report_bug(first_error->_id);
1102   if (!skip_bug_url) {
1103     skip_bug_url = true;
1104 
1105     out.print_raw_cr("#");
1106     print_bug_submit_message(&out, _thread);
1107   }
1108 
1109   if (!UseOSErrorReporting) {
1110     // os::abort() will call abort hooks, try it first.
1111     static bool skip_os_abort = false;
1112     if (!skip_os_abort) {
1113       skip_os_abort = true;
1114       bool dump_core = should_report_bug(first_error->_id);
1115       os::abort(dump_core && CreateCoredumpOnCrash, _siginfo, _context);
1116     }
1117 
1118     // if os::abort() doesn't abort, try os::die();
1119     os::die();
1120   }
1121 }
1122 
1123 /*
1124  * OnOutOfMemoryError scripts/commands executed while VM is a safepoint - this
1125  * ensures utilities such as jmap can observe the process is a consistent state.
1126  */
1127 class VM_ReportJavaOutOfMemory : public VM_Operation {
1128  private:
1129   VMError *_err;
1130  public:
1131   VM_ReportJavaOutOfMemory(VMError *err) { _err = err; }
1132   VMOp_Type type() const                 { return VMOp_ReportJavaOutOfMemory; }
1133   void doit();
1134 };
1135