1221 }
1222
1223 void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context)
1224 {
1225 report_and_die(thread, sig, pc, siginfo, context, "%s", "");
1226 }
1227
1228 void VMError::report_and_die(const char* message, const char* detail_fmt, ...)
1229 {
1230 va_list detail_args;
1231 va_start(detail_args, detail_fmt);
1232 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, NULL, NULL, NULL, NULL, NULL, 0, 0);
1233 va_end(detail_args);
1234 }
1235
1236 void VMError::report_and_die(const char* message)
1237 {
1238 report_and_die(message, "%s", "");
1239 }
1240
1241 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, const char* message,
1242 const char* detail_fmt, va_list detail_args)
1243 {
1244 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, 0);
1245 }
1246
1247 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
1248 VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) {
1249 report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size);
1250 }
1251
1252 void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
1253 Thread* thread, address pc, void* siginfo, void* context, const char* filename,
1254 int lineno, size_t size)
1255 {
1256 // Don't allocate large buffer on stack
1257 static char buffer[O_BUFLEN];
1258 out.set_scratch_buffer(buffer, sizeof(buffer));
1259 log.set_scratch_buffer(buffer, sizeof(buffer));
1260
1261 // How many errors occurred in error handler when reporting first_error.
1262 static int recursive_error_count;
1263
1264 // We will first print a brief message to standard out (verbose = false),
1657 if (how == 0) return;
1658
1659 // If asserts are disabled, use the corresponding guarantee instead.
1660 NOT_DEBUG(if (how <= 2) how += 2);
1661
1662 const char* const str = "hello";
1663 const size_t num = (size_t)os::vm_page_size();
1664
1665 const char* const eol = os::line_separator();
1666 const char* const msg = "this message should be truncated during formatting";
1667 char * const dataPtr = NULL; // bad data pointer
1668 const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
1669
1670 // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1671 // which tests cases 1 thru 13.
1672 // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1673 // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1674 // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
1675 // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
1676 switch (how) {
1677 case 1: vmassert(str == NULL, "expected null");
1678 case 2: vmassert(num == 1023 && *str == 'X',
1679 "num=" SIZE_FORMAT " str=\"%s\"", num, str);
1680 case 3: guarantee(str == NULL, "expected null");
1681 case 4: guarantee(num == 1023 && *str == 'X',
1682 "num=" SIZE_FORMAT " str=\"%s\"", num, str);
1683 case 5: fatal("expected null");
1684 case 6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str);
1685 case 7: fatal("%s%s# %s%s# %s%s# %s%s# %s%s# "
1686 "%s%s# %s%s# %s%s# %s%s# %s%s# "
1687 "%s%s# %s%s# %s%s# %s%s# %s",
1688 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1689 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1690 msg, eol, msg, eol, msg, eol, msg, eol, msg);
1691 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
1692 case 9: ShouldNotCallThis();
1693 case 10: ShouldNotReachHere();
1694 case 11: Unimplemented();
1695 // There's no guarantee the bad data pointer will crash us
1696 // so "break" out to the ShouldNotReachHere().
1697 case 12: *dataPtr = '\0'; break;
1698 // There's no guarantee the bad function pointer will crash us
1699 // so "break" out to the ShouldNotReachHere().
1700 case 13: (*funcPtr)(); break;
1701 case 14: crash_with_segfault(); break;
1702 case 15: crash_with_sigfpe(); break;
1703 case 16: {
1704 ThreadsListHandle tlh;
1705 fatal("Force crash with an active ThreadsListHandle.");
1706 }
1707 case 17: {
1708 ThreadsListHandle tlh;
1709 {
1710 ThreadsListHandle tlh2;
1711 fatal("Force crash with a nested ThreadsListHandle.");
1712 }
1713 }
1714
1715 default: tty->print_cr("ERROR: %d: unexpected test_num value.", how);
1716 }
1717 ShouldNotReachHere();
1718 }
1719 #endif // !PRODUCT
1720
|
1221 }
1222
1223 void VMError::report_and_die(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context)
1224 {
1225 report_and_die(thread, sig, pc, siginfo, context, "%s", "");
1226 }
1227
1228 void VMError::report_and_die(const char* message, const char* detail_fmt, ...)
1229 {
1230 va_list detail_args;
1231 va_start(detail_args, detail_fmt);
1232 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, NULL, NULL, NULL, NULL, NULL, 0, 0);
1233 va_end(detail_args);
1234 }
1235
1236 void VMError::report_and_die(const char* message)
1237 {
1238 report_and_die(message, "%s", "");
1239 }
1240
1241 void VMError::report_and_die(Thread* thread, void* context, const char* filename, int lineno, const char* message,
1242 const char* detail_fmt, va_list detail_args)
1243 {
1244 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, context, filename, lineno, 0);
1245 }
1246
1247 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
1248 VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) {
1249 report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size);
1250 }
1251
1252 void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
1253 Thread* thread, address pc, void* siginfo, void* context, const char* filename,
1254 int lineno, size_t size)
1255 {
1256 // Don't allocate large buffer on stack
1257 static char buffer[O_BUFLEN];
1258 out.set_scratch_buffer(buffer, sizeof(buffer));
1259 log.set_scratch_buffer(buffer, sizeof(buffer));
1260
1261 // How many errors occurred in error handler when reporting first_error.
1262 static int recursive_error_count;
1263
1264 // We will first print a brief message to standard out (verbose = false),
1657 if (how == 0) return;
1658
1659 // If asserts are disabled, use the corresponding guarantee instead.
1660 NOT_DEBUG(if (how <= 2) how += 2);
1661
1662 const char* const str = "hello";
1663 const size_t num = (size_t)os::vm_page_size();
1664
1665 const char* const eol = os::line_separator();
1666 const char* const msg = "this message should be truncated during formatting";
1667 char * const dataPtr = NULL; // bad data pointer
1668 const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
1669
1670 // Keep this in sync with test/hotspot/jtreg/runtime/ErrorHandling/ErrorHandler.java
1671 // which tests cases 1 thru 13.
1672 // Case 14 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SafeFetchInErrorHandlingTest.java.
1673 // Case 15 is tested by test/hotspot/jtreg/runtime/ErrorHandling/SecondaryErrorTest.java.
1674 // Case 16 is tested by test/hotspot/jtreg/runtime/ErrorHandling/ThreadsListHandleInErrorHandlingTest.java.
1675 // Case 17 is tested by test/hotspot/jtreg/runtime/ErrorHandling/NestedThreadsListHandleInErrorHandlingTest.java.
1676 switch (how) {
1677 case 1: vmassert(str == NULL, "expected null"); break;
1678 case 2: vmassert(num == 1023 && *str == 'X',
1679 "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1680 case 3: guarantee(str == NULL, "expected null"); break;
1681 case 4: guarantee(num == 1023 && *str == 'X',
1682 "num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1683 case 5: fatal("expected null"); break;
1684 case 6: fatal("num=" SIZE_FORMAT " str=\"%s\"", num, str); break;
1685 case 7: fatal("%s%s# %s%s# %s%s# %s%s# %s%s# "
1686 "%s%s# %s%s# %s%s# %s%s# %s%s# "
1687 "%s%s# %s%s# %s%s# %s%s# %s",
1688 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1689 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
1690 msg, eol, msg, eol, msg, eol, msg, eol, msg); break;
1691 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate"); break;
1692 case 9: ShouldNotCallThis(); break;
1693 case 10: ShouldNotReachHere(); break;
1694 case 11: Unimplemented(); break;
1695 // There's no guarantee the bad data pointer will crash us
1696 // so "break" out to the ShouldNotReachHere().
1697 case 12: *dataPtr = '\0'; break;
1698 // There's no guarantee the bad function pointer will crash us
1699 // so "break" out to the ShouldNotReachHere().
1700 case 13: (*funcPtr)(); break;
1701 case 14: crash_with_segfault(); break;
1702 case 15: crash_with_sigfpe(); break;
1703 case 16: {
1704 ThreadsListHandle tlh;
1705 fatal("Force crash with an active ThreadsListHandle.");
1706 }
1707 case 17: {
1708 ThreadsListHandle tlh;
1709 {
1710 ThreadsListHandle tlh2;
1711 fatal("Force crash with a nested ThreadsListHandle.");
1712 }
1713 }
1714
1715 default: tty->print_cr("ERROR: %d: unexpected test_num value.", how);
1716 }
1717 tty->print_cr("VMError::controlled_crash: survived intentional crash. Did you suppress the assert?");
1718 ShouldNotReachHere();
1719 }
1720 #endif // !PRODUCT
1721
|