341 // don't allocate large buffer on stack
342 static char buf[O_BUFLEN];
343
344 BEGIN
345
346 STEP(10, "(printing fatal error message)")
347
348 st->print_cr("#");
349 if (should_report_bug(_id)) {
350 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
351 } else {
352 st->print_cr("# There is insufficient memory for the Java "
353 "Runtime Environment to continue.");
354 }
355
356 #ifndef PRODUCT
357 // Error handler self tests
358
359 // test secondary error handling. Test it twice, to test that resetting
360 // error handler after a secondary crash works.
361 STEP(13, "(test secondary crash 1)")
362 if (_verbose && TestCrashInErrorHandler != 0) {
363 st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
364 TestCrashInErrorHandler);
365 controlled_crash(TestCrashInErrorHandler);
366 }
367
368 STEP(14, "(test secondary crash 2)")
369 if (_verbose && TestCrashInErrorHandler != 0) {
370 st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
371 TestCrashInErrorHandler);
372 controlled_crash(TestCrashInErrorHandler);
373 }
374 #endif // PRODUCT
375
376 STEP(15, "(printing type of error)")
377
378 switch(_id) {
379 case OOM_MALLOC_ERROR:
380 case OOM_MMAP_ERROR:
381 if (_size) {
382 st->print("# Native memory allocation ");
383 st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
384 "(mmap) failed to map ");
385 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
386 st->print("%s", buf);
387 st->print(" bytes");
388 if (_message != NULL) {
389 st->print(" for ");
390 st->print("%s", _message);
391 }
392 st->cr();
393 } else {
|
341 // don't allocate large buffer on stack
342 static char buf[O_BUFLEN];
343
344 BEGIN
345
346 STEP(10, "(printing fatal error message)")
347
348 st->print_cr("#");
349 if (should_report_bug(_id)) {
350 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:");
351 } else {
352 st->print_cr("# There is insufficient memory for the Java "
353 "Runtime Environment to continue.");
354 }
355
356 #ifndef PRODUCT
357 // Error handler self tests
358
359 // test secondary error handling. Test it twice, to test that resetting
360 // error handler after a secondary crash works.
361 STEP(11, "(test secondary crash 1)")
362 if (_verbose && TestCrashInErrorHandler != 0) {
363 st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
364 TestCrashInErrorHandler);
365 controlled_crash(TestCrashInErrorHandler);
366 }
367
368 STEP(12, "(test secondary crash 2)")
369 if (_verbose && TestCrashInErrorHandler != 0) {
370 st->print_cr("Will crash now (TestCrashInErrorHandler=%d)...",
371 TestCrashInErrorHandler);
372 controlled_crash(TestCrashInErrorHandler);
373 }
374
375 STEP(13, "(test safefetch in error handler)")
376 // test whether it is safe to use SafeFetch32 in Crash Handler. Test twice
377 // to test that resetting the signal handler works correctly.
378 if (_verbose && TestSafeFetchInErrorHandler) {
379 st->print_cr("Will test SafeFetch...");
380 if (CanUseSafeFetch32()) {
381 int* const invalid_pointer = (int*) get_segfault_address();
382 const int x = 0x76543210;
383 int i1 = SafeFetch32(invalid_pointer, x);
384 int i2 = SafeFetch32(invalid_pointer, x);
385 if (i1 == x && i2 == x) {
386 st->print_cr("SafeFetch OK."); // Correctly deflected and returned default pattern
387 } else {
388 st->print_cr("??");
389 }
390 } else {
391 st->print_cr("not possible; skipped.");
392 }
393 }
394 #endif // PRODUCT
395
396 STEP(15, "(printing type of error)")
397
398 switch(_id) {
399 case OOM_MALLOC_ERROR:
400 case OOM_MMAP_ERROR:
401 if (_size) {
402 st->print("# Native memory allocation ");
403 st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
404 "(mmap) failed to map ");
405 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
406 st->print("%s", buf);
407 st->print(" bytes");
408 if (_message != NULL) {
409 st->print(" for ");
410 st->print("%s", _message);
411 }
412 st->cr();
413 } else {
|