306 report_vm_error(file, line, "ShouldNotReachHere()");
307 }
308
309 void report_unimplemented(const char* file, int line) {
310 report_vm_error(file, line, "Unimplemented()");
311 }
312
313 void report_untested(const char* file, int line, const char* message) {
314 #ifndef PRODUCT
315 warning("Untested: %s in %s: %d\n", message, file, line);
316 #endif // !PRODUCT
317 }
318
319 void report_java_out_of_memory(const char* message) {
320 static int out_of_memory_reported = 0;
321
322 // A number of threads may attempt to report OutOfMemoryError at around the
323 // same time. To avoid dumping the heap or executing the data collection
324 // commands multiple times we just do it once when the first threads reports
325 // the error.
326 if (Atomic::cmpxchg(1, &out_of_memory_reported, 0) == 0) {
327 // create heap dump before OnOutOfMemoryError commands are executed
328 if (HeapDumpOnOutOfMemoryError) {
329 tty->print_cr("java.lang.OutOfMemoryError: %s", message);
330 HeapDumper::dump_heap_from_oome();
331 }
332
333 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
334 VMError::report_java_out_of_memory(message);
335 }
336
337 if (CrashOnOutOfMemoryError) {
338 tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message);
339 fatal("OutOfMemory encountered: %s", message);
340 }
341
342 if (ExitOnOutOfMemoryError) {
343 tty->print_cr("Terminating due to java.lang.OutOfMemoryError: %s", message);
344 os::exit(3);
345 }
346 }
745 // on Linux ppc64, ucontext_t contains pointers into itself which have to be patched up
746 // after copying the context (see comment in sys/ucontext.h):
747 *((void**) &g_stored_assertion_context.uc_mcontext.regs) = &(g_stored_assertion_context.uc_mcontext.gp_regs);
748 #endif
749 }
750
751 bool handle_assert_poison_fault(const void* ucVoid, const void* faulting_address) {
752 if (faulting_address == g_assert_poison) {
753 // Disarm poison page.
754 if (os::protect_memory((char*)g_assert_poison, os::vm_page_size(), os::MEM_PROT_RWX) == false) {
755 #ifdef ASSERT
756 fprintf(stderr, "Assertion poison page cannot be unprotected - mprotect failed with %d (%s)",
757 errno, os::strerror(errno));
758 fflush(stderr);
759 #endif
760 return false; // unprotecting memory may fail in OOM situations, as surprising as this sounds.
761 }
762 // Store Context away.
763 if (ucVoid) {
764 const intx my_tid = os::current_thread_id();
765 if (Atomic::cmpxchg(my_tid, &g_asserting_thread, (intx)0) == 0) {
766 store_context(ucVoid);
767 g_assertion_context = &g_stored_assertion_context;
768 }
769 }
770 return true;
771 }
772 return false;
773 }
774 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
775
|
306 report_vm_error(file, line, "ShouldNotReachHere()");
307 }
308
309 void report_unimplemented(const char* file, int line) {
310 report_vm_error(file, line, "Unimplemented()");
311 }
312
313 void report_untested(const char* file, int line, const char* message) {
314 #ifndef PRODUCT
315 warning("Untested: %s in %s: %d\n", message, file, line);
316 #endif // !PRODUCT
317 }
318
319 void report_java_out_of_memory(const char* message) {
320 static int out_of_memory_reported = 0;
321
322 // A number of threads may attempt to report OutOfMemoryError at around the
323 // same time. To avoid dumping the heap or executing the data collection
324 // commands multiple times we just do it once when the first threads reports
325 // the error.
326 if (Atomic::cmpxchg(&out_of_memory_reported, 0, 1) == 0) {
327 // create heap dump before OnOutOfMemoryError commands are executed
328 if (HeapDumpOnOutOfMemoryError) {
329 tty->print_cr("java.lang.OutOfMemoryError: %s", message);
330 HeapDumper::dump_heap_from_oome();
331 }
332
333 if (OnOutOfMemoryError && OnOutOfMemoryError[0]) {
334 VMError::report_java_out_of_memory(message);
335 }
336
337 if (CrashOnOutOfMemoryError) {
338 tty->print_cr("Aborting due to java.lang.OutOfMemoryError: %s", message);
339 fatal("OutOfMemory encountered: %s", message);
340 }
341
342 if (ExitOnOutOfMemoryError) {
343 tty->print_cr("Terminating due to java.lang.OutOfMemoryError: %s", message);
344 os::exit(3);
345 }
346 }
745 // on Linux ppc64, ucontext_t contains pointers into itself which have to be patched up
746 // after copying the context (see comment in sys/ucontext.h):
747 *((void**) &g_stored_assertion_context.uc_mcontext.regs) = &(g_stored_assertion_context.uc_mcontext.gp_regs);
748 #endif
749 }
750
751 bool handle_assert_poison_fault(const void* ucVoid, const void* faulting_address) {
752 if (faulting_address == g_assert_poison) {
753 // Disarm poison page.
754 if (os::protect_memory((char*)g_assert_poison, os::vm_page_size(), os::MEM_PROT_RWX) == false) {
755 #ifdef ASSERT
756 fprintf(stderr, "Assertion poison page cannot be unprotected - mprotect failed with %d (%s)",
757 errno, os::strerror(errno));
758 fflush(stderr);
759 #endif
760 return false; // unprotecting memory may fail in OOM situations, as surprising as this sounds.
761 }
762 // Store Context away.
763 if (ucVoid) {
764 const intx my_tid = os::current_thread_id();
765 if (Atomic::cmpxchg(&g_asserting_thread, (intx)0, my_tid) == 0) {
766 store_context(ucVoid);
767 g_assertion_context = &g_stored_assertion_context;
768 }
769 }
770 return true;
771 }
772 return false;
773 }
774 #endif // CAN_SHOW_REGISTERS_ON_ASSERT
|