< prev index next >

src/hotspot/share/utilities/vmError.cpp

Print this page
rev 54181 : 8221175: Fix bad function case for controlled JVM crash on PPC64 big-endian
Reviewed-by:


1708 // 5-7 - fatal
1709 // 8 - vm_exit_out_of_memory
1710 // 9 - ShouldNotCallThis
1711 // 10 - ShouldNotReachHere
1712 // 11 - Unimplemented
1713 // 12,13 - (not guaranteed) crashes
1714 // 14 - SIGSEGV
1715 // 15 - SIGFPE
1716 void VMError::controlled_crash(int how) {
1717   if (how == 0) return;
1718 
1719   // If asserts are disabled, use the corresponding guarantee instead.
1720   NOT_DEBUG(if (how <= 2) how += 2);
1721 
1722   const char* const str = "hello";
1723   const size_t      num = (size_t)os::vm_page_size();
1724 
1725   const char* const eol = os::line_separator();
1726   const char* const msg = "this message should be truncated during formatting";
1727   char * const dataPtr = NULL;  // bad data pointer
1728   const void (*funcPtr)(void) = (const void(*)()) 0xF;  // bad function pointer







1729 
1730   // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1731   // which tests cases 1 thru 13.
1732   // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1733   // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1734   // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
1735   // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
1736 
1737   // We grab Threads_lock to keep ThreadsSMRSupport::print_info_on()
1738   // from racing with Threads::add() or Threads::remove() as we
1739   // generate the hs_err_pid file. This makes our ErrorHandling tests
1740   // more stable.
1741   MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock, Mutex::_no_safepoint_check_flag);
1742 
1743   switch (how) {
1744     case  1: vmassert(str == NULL, "expected null"); break;
1745     case  2: vmassert(num == 1023 && *str == 'X',
1746                       "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1747     case  3: guarantee(str == NULL, "expected null"); break;
1748     case  4: guarantee(num == 1023 && *str == 'X',




1708 // 5-7 - fatal
1709 // 8 - vm_exit_out_of_memory
1710 // 9 - ShouldNotCallThis
1711 // 10 - ShouldNotReachHere
1712 // 11 - Unimplemented
1713 // 12,13 - (not guaranteed) crashes
1714 // 14 - SIGSEGV
1715 // 15 - SIGFPE
1716 void VMError::controlled_crash(int how) {
1717   if (how == 0) return;
1718 
1719   // If asserts are disabled, use the corresponding guarantee instead.
1720   NOT_DEBUG(if (how <= 2) how += 2);
1721 
1722   const char* const str = "hello";
1723   const size_t      num = (size_t)os::vm_page_size();
1724 
1725   const char* const eol = os::line_separator();
1726   const char* const msg = "this message should be truncated during formatting";
1727   char * const dataPtr = NULL;  // bad data pointer
1728   const void (*funcPtr)(void);  // bad function pointer
1729 
1730 #if defined(PPC64) && !defined(ABI_ELFv2)
1731   unsigned long function_descriptor[] = { 0xF /* function pointer */, 0x0, 0x0 };
1732   funcPtr = (const void(*)()) &function_descriptor;
1733 #else
1734   funcPtr = (const void(*)()) 0xF;
1735 #endif
1736 
1737   // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1738   // which tests cases 1 thru 13.
1739   // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1740   // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1741   // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
1742   // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
1743 
1744   // We grab Threads_lock to keep ThreadsSMRSupport::print_info_on()
1745   // from racing with Threads::add() or Threads::remove() as we
1746   // generate the hs_err_pid file. This makes our ErrorHandling tests
1747   // more stable.
1748   MutexLockerEx ml(Threads_lock->owned_by_self() ? NULL : Threads_lock, Mutex::_no_safepoint_check_flag);
1749 
1750   switch (how) {
1751     case  1: vmassert(str == NULL, "expected null"); break;
1752     case  2: vmassert(num == 1023 && *str == 'X',
1753                       "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1754     case  3: guarantee(str == NULL, "expected null"); break;
1755     case  4: guarantee(num == 1023 && *str == 'X',


< prev index next >