< prev index next >

src/share/vm/utilities/vmError.cpp

Print this page
rev 7752 : 8065895: Synchronous signals during error reporting may terminate or hang VM process
Contributed-by: stuefe
Reviewed-by: dholmes


 336 void VMError::report(outputStream* st) {
 337 # define BEGIN if (_current_step == 0) { _current_step = 1;
 338 # define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s;
 339 # define END }
 340 
 341   // don't allocate large buffer on stack
 342   static char buf[O_BUFLEN];
 343 
 344   BEGIN
 345 
 346   STEP(10, "(printing fatal error message)")
 347 
 348     st->print_cr("#");
 349     if (should_report_bug(_id)) {
 350       st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
 351     } else {
 352       st->print_cr("# There is insufficient memory for the Java "
 353                    "Runtime Environment to continue.");
 354     }
 355 
















 356   STEP(15, "(printing type of error)")
 357 
 358      switch(_id) {
 359        case OOM_MALLOC_ERROR:
 360        case OOM_MMAP_ERROR:
 361          if (_size) {
 362            st->print("# Native memory allocation ");
 363            st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
 364                                                  "(mmap) failed to map ");
 365            jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
 366            st->print("%s", buf);
 367            st->print(" bytes");
 368            if (_message != NULL) {
 369              st->print(" for ");
 370              st->print("%s", _message);
 371            }
 372            st->cr();
 373          } else {
 374            if (_message != NULL)
 375              st->print("# ");


 768   STEP(260, "(printing memory info)" )
 769 
 770      if (_verbose) {
 771        os::print_memory_info(st);
 772        st->cr();
 773      }
 774 
 775   STEP(270, "(printing internal vm info)" )
 776 
 777      if (_verbose) {
 778        st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
 779        st->cr();
 780      }
 781 
 782   STEP(280, "(printing date and time)" )
 783 
 784      if (_verbose) {
 785        os::print_date_and_time(st);
 786        st->cr();
 787      }









 788 
 789   END
 790 
 791 # undef BEGIN
 792 # undef STEP
 793 # undef END
 794 }
 795 
 796 VMError* volatile VMError::first_error = NULL;
 797 volatile jlong VMError::first_error_tid = -1;
 798 
 799 // An error could happen before tty is initialized or after it has been
 800 // destroyed. Here we use a very simple unbuffered fdStream for printing.
 801 // Only out.print_raw() and out.print_raw_cr() should be used, as other
 802 // printing methods need to allocate large buffer on stack. To format a
 803 // string, use jio_snprintf() with a static buffer or use staticBufferStream.
 804 fdStream VMError::out(defaultStream::output_fd());
 805 fdStream VMError::log; // error log used by VMError::report_and_die()
 806 
 807 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */




 336 void VMError::report(outputStream* st) {
 337 # define BEGIN if (_current_step == 0) { _current_step = 1;
 338 # define STEP(n, s) } if (_current_step < n) { _current_step = n; _current_step_info = s;
 339 # define END }
 340 
 341   // don't allocate large buffer on stack
 342   static char buf[O_BUFLEN];
 343 
 344   BEGIN
 345 
 346   STEP(10, "(printing fatal error message)")
 347 
 348     st->print_cr("#");
 349     if (should_report_bug(_id)) {
 350       st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
 351     } else {
 352       st->print_cr("# There is insufficient memory for the Java "
 353                    "Runtime Environment to continue.");
 354     }
 355 
 356 #ifndef PRODUCT
 357   // Error handler self tests
 358 
 359   // test secondary error handling. Test it twice, to test that resetting
 360   // error handler after a secondary crash works.
 361   STEP(13, "(test secondary crash 1)")
 362     if (TestCrashInErrorHandler != 0) {
 363       controlled_crash(TestCrashInErrorHandler);
 364     }
 365 
 366   STEP(14, "(test secondary crash 2)")
 367     if (TestCrashInErrorHandler != 0) {
 368       controlled_crash(TestCrashInErrorHandler);
 369     }
 370 #endif // PRODUCT
 371 
 372   STEP(15, "(printing type of error)")
 373 
 374      switch(_id) {
 375        case OOM_MALLOC_ERROR:
 376        case OOM_MMAP_ERROR:
 377          if (_size) {
 378            st->print("# Native memory allocation ");
 379            st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
 380                                                  "(mmap) failed to map ");
 381            jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
 382            st->print("%s", buf);
 383            st->print(" bytes");
 384            if (_message != NULL) {
 385              st->print(" for ");
 386              st->print("%s", _message);
 387            }
 388            st->cr();
 389          } else {
 390            if (_message != NULL)
 391              st->print("# ");


 784   STEP(260, "(printing memory info)" )
 785 
 786      if (_verbose) {
 787        os::print_memory_info(st);
 788        st->cr();
 789      }
 790 
 791   STEP(270, "(printing internal vm info)" )
 792 
 793      if (_verbose) {
 794        st->print_cr("vm_info: %s", Abstract_VM_Version::internal_vm_info_string());
 795        st->cr();
 796      }
 797 
 798   STEP(280, "(printing date and time)" )
 799 
 800      if (_verbose) {
 801        os::print_date_and_time(st);
 802        st->cr();
 803      }
 804 
 805 #ifdef PRODUCT
 806   // print a defined marker to show that error handling finished correctly.
 807   STEP(290, "(printing end marker)" )
 808 
 809      if (_verbose) {
 810        st->print_cr("END.");
 811      }
 812 #endif
 813 
 814   END
 815 
 816 # undef BEGIN
 817 # undef STEP
 818 # undef END
 819 }
 820 
 821 VMError* volatile VMError::first_error = NULL;
 822 volatile jlong VMError::first_error_tid = -1;
 823 
 824 // An error could happen before tty is initialized or after it has been
 825 // destroyed. Here we use a very simple unbuffered fdStream for printing.
 826 // Only out.print_raw() and out.print_raw_cr() should be used, as other
 827 // printing methods need to allocate large buffer on stack. To format a
 828 // string, use jio_snprintf() with a static buffer or use staticBufferStream.
 829 fdStream VMError::out(defaultStream::output_fd());
 830 fdStream VMError::log; // error log used by VMError::report_and_die()
 831 
 832 /** Expand a pattern into a buffer starting at pos and open a file using constructed path */


< prev index next >