< prev index next >

src/hotspot/share/utilities/vmError.cpp

Print this page
rev 47287 : Port 09.17.Thread_SMR_logging_update from JDK9 to JDK10
rev 47289 : eosterlund, stefank CR - refactor code into threadSMR.cpp and threadSMR.hpp


  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "compiler/compileBroker.hpp"
  28 #include "compiler/disassembler.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "logging/logConfiguration.hpp"
  31 #include "prims/jvm.h"
  32 #include "prims/whitebox.hpp"
  33 #include "runtime/arguments.hpp"
  34 #include "runtime/atomic.hpp"
  35 #include "runtime/frame.inline.hpp"
  36 #include "runtime/init.hpp"
  37 #include "runtime/os.hpp"
  38 #include "runtime/thread.inline.hpp"

  39 #include "runtime/vmThread.hpp"
  40 #include "runtime/vm_operations.hpp"
  41 #include "runtime/vm_version.hpp"
  42 #include "services/memTracker.hpp"
  43 #include "trace/traceMacros.hpp"
  44 #include "utilities/debug.hpp"
  45 #include "utilities/decoder.hpp"
  46 #include "utilities/defaultStream.hpp"
  47 #include "utilities/errorReporter.hpp"
  48 #include "utilities/events.hpp"
  49 #include "utilities/vmError.hpp"
  50 
  51 #ifndef PRODUCT
  52 #include <signal.h>
  53 #endif // PRODUCT
  54 
  55 bool VMError::_error_reported = false;
  56 
  57 // call this when the VM is dying--it might loosen some asserts
  58 bool VMError::is_error_reported() { return _error_reported; }


1641 // 9 - ShouldNotCallThis
1642 // 10 - ShouldNotReachHere
1643 // 11 - Unimplemented
1644 // 12,13 - (not guaranteed) crashes
1645 // 14 - SIGSEGV
1646 // 15 - SIGFPE
1647 void VMError::controlled_crash(int how) {
1648   if (how == 0) return;
1649 
1650   // If asserts are disabled, use the corresponding guarantee instead.
1651   NOT_DEBUG(if (how <= 2) how += 2);
1652 
1653   const char* const str = "hello";
1654   const size_t      num = (size_t)os::vm_page_size();
1655 
1656   const char* const eol = os::line_separator();
1657   const char* const msg = "this message should be truncated during formatting";
1658   char * const dataPtr = NULL;  // bad data pointer
1659   const void (*funcPtr)(void) = (const void(*)()) 0xF;  // bad function pointer
1660 
1661   // Keep this in sync with test/runtime/ErrorHandling/ErrorHandler.java





1662   switch (how) {
1663     case  1: vmassert(str == NULL, "expected null");
1664     case  2: vmassert(num == 1023 && *str == 'X',
1665                       "num=" SIZE_FORMAT " str=\"%s\"", num, str);
1666     case  3: guarantee(str == NULL, "expected null");
1667     case  4: guarantee(num == 1023 && *str == 'X',
1668                        "num=" SIZE_FORMAT " str=\"%s\"", num, str);
1669     case  5: fatal("expected null");
1670     case  6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str);
1671     case  7: fatal("%s%s#    %s%s#    %s%s#    %s%s#    %s%s#    "
1672                    "%s%s#    %s%s#    %s%s#    %s%s#    %s%s#    "
1673                    "%s%s#    %s%s#    %s%s#    %s%s#    %s",
1674                    msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1675                    msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1676                    msg, eol, msg, eol, msg, eol, msg, eol, msg);
1677     case  8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
1678     case  9: ShouldNotCallThis();
1679     case 10: ShouldNotReachHere();
1680     case 11: Unimplemented();
1681     // There's no guarantee the bad data pointer will crash us
1682     // so "break" out to the ShouldNotReachHere().
1683     case 12: *dataPtr = '\0'; break;
1684     // There's no guarantee the bad function pointer will crash us
1685     // so "break" out to the ShouldNotReachHere().
1686     case 13: (*funcPtr)(); break;
1687     case 14: crash_with_segfault(); break;
1688     case 15: crash_with_sigfpe(); break;











1689 
1690     default: tty->print_cr("ERROR: %d: unexpected test_num value.", how);
1691   }
1692   ShouldNotReachHere();
1693 }
1694 #endif // !PRODUCT
1695 


  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  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "code/codeCache.hpp"
  27 #include "compiler/compileBroker.hpp"
  28 #include "compiler/disassembler.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "logging/logConfiguration.hpp"
  31 #include "prims/jvm.h"
  32 #include "prims/whitebox.hpp"
  33 #include "runtime/arguments.hpp"
  34 #include "runtime/atomic.hpp"
  35 #include "runtime/frame.inline.hpp"
  36 #include "runtime/init.hpp"
  37 #include "runtime/os.hpp"
  38 #include "runtime/thread.inline.hpp"
  39 #include "runtime/threadSMR.hpp"
  40 #include "runtime/vmThread.hpp"
  41 #include "runtime/vm_operations.hpp"
  42 #include "runtime/vm_version.hpp"
  43 #include "services/memTracker.hpp"
  44 #include "trace/traceMacros.hpp"
  45 #include "utilities/debug.hpp"
  46 #include "utilities/decoder.hpp"
  47 #include "utilities/defaultStream.hpp"
  48 #include "utilities/errorReporter.hpp"
  49 #include "utilities/events.hpp"
  50 #include "utilities/vmError.hpp"
  51 
  52 #ifndef PRODUCT
  53 #include <signal.h>
  54 #endif // PRODUCT
  55 
  56 bool VMError::_error_reported = false;
  57 
  58 // call this when the VM is dying--it might loosen some asserts
  59 bool VMError::is_error_reported() { return _error_reported; }


1642 // 9 - ShouldNotCallThis
1643 // 10 - ShouldNotReachHere
1644 // 11 - Unimplemented
1645 // 12,13 - (not guaranteed) crashes
1646 // 14 - SIGSEGV
1647 // 15 - SIGFPE
1648 void VMError::controlled_crash(int how) {
1649   if (how == 0) return;
1650 
1651   // If asserts are disabled, use the corresponding guarantee instead.
1652   NOT_DEBUG(if (how <= 2) how += 2);
1653 
1654   const char* const str = "hello";
1655   const size_t      num = (size_t)os::vm_page_size();
1656 
1657   const char* const eol = os::line_separator();
1658   const char* const msg = "this message should be truncated during formatting";
1659   char * const dataPtr = NULL;  // bad data pointer
1660   const void (*funcPtr)(void) = (const void(*)()) 0xF;  // bad function pointer
1661 
1662   // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1663   // which tests cases 1 thru 13.
1664   // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1665   // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1666   // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
1667   // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
1668   switch (how) {
1669     case  1: vmassert(str == NULL, "expected null");
1670     case  2: vmassert(num == 1023 && *str == 'X',
1671                       "num=" SIZE_FORMAT " str=\"%s\"", num, str);
1672     case  3: guarantee(str == NULL, "expected null");
1673     case  4: guarantee(num == 1023 && *str == 'X',
1674                        "num=" SIZE_FORMAT " str=\"%s\"", num, str);
1675     case  5: fatal("expected null");
1676     case  6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str);
1677     case  7: fatal("%s%s#    %s%s#    %s%s#    %s%s#    %s%s#    "
1678                    "%s%s#    %s%s#    %s%s#    %s%s#    %s%s#    "
1679                    "%s%s#    %s%s#    %s%s#    %s%s#    %s",
1680                    msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1681                    msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1682                    msg, eol, msg, eol, msg, eol, msg, eol, msg);
1683     case  8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
1684     case  9: ShouldNotCallThis();
1685     case 10: ShouldNotReachHere();
1686     case 11: Unimplemented();
1687     // There's no guarantee the bad data pointer will crash us
1688     // so "break" out to the ShouldNotReachHere().
1689     case 12: *dataPtr = '\0'; break;
1690     // There's no guarantee the bad function pointer will crash us
1691     // so "break" out to the ShouldNotReachHere().
1692     case 13: (*funcPtr)(); break;
1693     case 14: crash_with_segfault(); break;
1694     case 15: crash_with_sigfpe(); break;
1695     case 16: {
1696       ThreadsListHandle tlh;
1697       fatal("Force crash with an active ThreadsListHandle.");
1698     }
1699     case 17: {
1700       ThreadsListHandle tlh;
1701       {
1702         ThreadsListHandle tlh2;
1703         fatal("Force crash with a nested ThreadsListHandle.");
1704       }
1705     }
1706 
1707     default: tty->print_cr("ERROR: %d: unexpected test_num value.", how);
1708   }
1709   ShouldNotReachHere();
1710 }
1711 #endif // !PRODUCT
1712 
< prev index next >