309 #include <signal.h>
310
311 void test_error_handler() {
312 uintx test_num = ErrorHandlerTest;
313 if (test_num == 0) return;
314
315 // If asserts are disabled, use the corresponding guarantee instead.
316 size_t n = test_num;
317 NOT_DEBUG(if (n <= 2) n += 2);
318
319 const char* const str = "hello";
320 const size_t num = (size_t)os::vm_page_size();
321
322 const char* const eol = os::line_separator();
323 const char* const msg = "this message should be truncated during formatting";
324 char * const dataPtr = NULL; // bad data pointer
325 const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
326
327 // Keep this in sync with test/runtime/6888954/vmerrors.sh.
328 switch (n) {
329 case 1: assert(str == NULL, "expected null");
330 case 2: assert(num == 1023 && *str == 'X',
331 err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
332 case 3: guarantee(str == NULL, "expected null");
333 case 4: guarantee(num == 1023 && *str == 'X',
334 err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
335 case 5: fatal("expected null");
336 case 6: fatal(err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
337 case 7: fatal(err_msg("%s%s# %s%s# %s%s# %s%s# %s%s# "
338 "%s%s# %s%s# %s%s# %s%s# %s%s# "
339 "%s%s# %s%s# %s%s# %s%s# %s",
340 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
341 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
342 msg, eol, msg, eol, msg, eol, msg, eol, msg));
343 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
344 case 9: ShouldNotCallThis();
345 case 10: ShouldNotReachHere();
346 case 11: Unimplemented();
347 // There's no guarantee the bad data pointer will crash us
348 // so "break" out to the ShouldNotReachHere().
349 case 12: *dataPtr = '\0'; break;
350 // There's no guarantee the bad function pointer will crash us
|
309 #include <signal.h>
310
311 void test_error_handler() {
312 uintx test_num = ErrorHandlerTest;
313 if (test_num == 0) return;
314
315 // If asserts are disabled, use the corresponding guarantee instead.
316 size_t n = test_num;
317 NOT_DEBUG(if (n <= 2) n += 2);
318
319 const char* const str = "hello";
320 const size_t num = (size_t)os::vm_page_size();
321
322 const char* const eol = os::line_separator();
323 const char* const msg = "this message should be truncated during formatting";
324 char * const dataPtr = NULL; // bad data pointer
325 const void (*funcPtr)(void) = (const void(*)()) 0xF; // bad function pointer
326
327 // Keep this in sync with test/runtime/6888954/vmerrors.sh.
328 switch (n) {
329 case 1: vmassert(str == NULL, "expected null");
330 case 2: vmassert(num == 1023 && *str == 'X',
331 err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
332 case 3: guarantee(str == NULL, "expected null");
333 case 4: guarantee(num == 1023 && *str == 'X',
334 err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
335 case 5: fatal("expected null");
336 case 6: fatal(err_msg("num=" SIZE_FORMAT " str=\"%s\"", num, str));
337 case 7: fatal(err_msg("%s%s# %s%s# %s%s# %s%s# %s%s# "
338 "%s%s# %s%s# %s%s# %s%s# %s%s# "
339 "%s%s# %s%s# %s%s# %s%s# %s",
340 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
341 msg, eol, msg, eol, msg, eol, msg, eol, msg, eol,
342 msg, eol, msg, eol, msg, eol, msg, eol, msg));
343 case 8: vm_exit_out_of_memory(num, OOM_MALLOC_ERROR, "ChunkPool::allocate");
344 case 9: ShouldNotCallThis();
345 case 10: ShouldNotReachHere();
346 case 11: Unimplemented();
347 // There's no guarantee the bad data pointer will crash us
348 // so "break" out to the ShouldNotReachHere().
349 case 12: *dataPtr = '\0'; break;
350 // There's no guarantee the bad function pointer will crash us
|