< prev index next >

src/hotspot/share/utilities/vmError.cpp

Print this page
rev 47819 : imported patch 10.07.open.rebase_20171110.dcubed


  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 "jvm.h"
  27 #include "code/codeCache.hpp"
  28 #include "compiler/compileBroker.hpp"
  29 #include "compiler/disassembler.hpp"
  30 #include "gc/shared/collectedHeap.hpp"
  31 #include "logging/logConfiguration.hpp"
  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; }


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





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











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


  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 "jvm.h"
  27 #include "code/codeCache.hpp"
  28 #include "compiler/compileBroker.hpp"
  29 #include "compiler/disassembler.hpp"
  30 #include "gc/shared/collectedHeap.hpp"
  31 #include "logging/logConfiguration.hpp"
  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; }


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