1681 void VMError::controlled_crash(int how) {
1682 if (how == 0) return;
1683
1684 // If asserts are disabled, use the corresponding guarantee instead.
1685 NOT_DEBUG(if (how <= 2) how += 2);
1686
1687 const char* const str = "hello";
1688 const size_t num = (size_t)os::vm_page_size();
1689
1690 const char* const eol = os::line_separator();
1691 const char* const msg = "this message should be truncated during formatting";
1692 char * const dataPtr = NULL; // bad data pointer
1693 const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
1694
1695 // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1696 // which tests cases 1 thru 13.
1697 // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1698 // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1699 // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
1700 // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
1701 switch (how) {
1702 case 1: vmassert(str == NULL, "expected null"); break;
1703 case 2: vmassert(num == 1023 && *str == 'X',
1704 "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1705 case 3: guarantee(str == NULL, "expected null"); break;
1706 case 4: guarantee(num == 1023 && *str == 'X',
1707 "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1708 case 5: fatal("expected null"); break;
1709 case 6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1710 case 7: fatal("%s%s# %s%s# %s%s# %s%s# %s%s# "
1711 "%s%s# %s%s# %s%s# %s%s# %s%s# "
1712 "%s%s# %s%s# %s%s# %s%s# %s",
1713 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1714 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1715 msg, eol, msg, eol, msg, eol, msg, eol, msg); break;
1716 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate"); break;
1717 case 9: ShouldNotCallThis(); break;
1718 case 10: ShouldNotReachHere(); break;
1719 case 11: Unimplemented(); break;
1720 // There's no guarantee the bad data pointer will crash us
|
1681 void VMError::controlled_crash(int how) {
1682 if (how == 0) return;
1683
1684 // If asserts are disabled, use the corresponding guarantee instead.
1685 NOT_DEBUG(if (how <= 2) how += 2);
1686
1687 const char* const str = "hello";
1688 const size_t num = (size_t)os::vm_page_size();
1689
1690 const char* const eol = os::line_separator();
1691 const char* const msg = "this message should be truncated during formatting";
1692 char * const dataPtr = NULL; // bad data pointer
1693 const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
1694
1695 // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1696 // which tests cases 1 thru 13.
1697 // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1698 // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1699 // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
1700 // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
1701
1702 // We grab Threads_lock to keep ThreadsSMRSupport::print_info_on()
1703 // from racing with Threads::add() or Threads::remove() as we
1704 // generate the hs_err_pid file. This makes our ErrorHandling tests
1705 // more stable.
1706 MutexLockerEx ml(Threads_lock, Mutex::_no_safepoint_check_flag);
1707
1708 switch (how) {
1709 case 1: vmassert(str == NULL, "expected null"); break;
1710 case 2: vmassert(num == 1023 && *str == 'X',
1711 "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1712 case 3: guarantee(str == NULL, "expected null"); break;
1713 case 4: guarantee(num == 1023 && *str == 'X',
1714 "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1715 case 5: fatal("expected null"); break;
1716 case 6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1717 case 7: fatal("%s%s# %s%s# %s%s# %s%s# %s%s# "
1718 "%s%s# %s%s# %s%s# %s%s# %s%s# "
1719 "%s%s# %s%s# %s%s# %s%s# %s",
1720 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1721 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1722 msg, eol, msg, eol, msg, eol, msg, eol, msg); break;
1723 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate"); break;
1724 case 9: ShouldNotCallThis(); break;
1725 case 10: ShouldNotReachHere(); break;
1726 case 11: Unimplemented(); break;
1727 // There's no guarantee the bad data pointer will crash us
|