Mercurial > hg > graal-jvmci-8
comparison src/share/vm/utilities/vmError.cpp @ 2095:36c186bcc085
6302804: Hotspot VM dies ungraceful death when C heap is exhausted in various places.
Summary: enhance the error reporting mechanism to help user to fix the problem rather than making it look like a VM error.
Reviewed-by: kvn, kamg
author | coleenp |
---|---|
date | Mon, 03 Jan 2011 14:09:11 -0500 |
parents | 2d4762ec74af |
children | 34d64ad817f4 |
comparison
equal
deleted
inserted
replaced
2075:06e4b9c9db76 | 2095:36c186bcc085 |
---|---|
65 // threads are having troubles at the same time, only one error is reported. | 65 // threads are having troubles at the same time, only one error is reported. |
66 // The thread that is reporting error will abort VM when it is done, all other | 66 // The thread that is reporting error will abort VM when it is done, all other |
67 // threads are blocked forever inside report_and_die(). | 67 // threads are blocked forever inside report_and_die(). |
68 | 68 |
69 // Constructor for crashes | 69 // Constructor for crashes |
70 VMError::VMError(Thread* thread, int sig, address pc, void* siginfo, void* context) { | 70 VMError::VMError(Thread* thread, unsigned int sig, address pc, void* siginfo, void* context) { |
71 _thread = thread; | 71 _thread = thread; |
72 _id = sig; | 72 _id = sig; |
73 _pc = pc; | 73 _pc = pc; |
74 _siginfo = siginfo; | 74 _siginfo = siginfo; |
75 _context = context; | 75 _context = context; |
320 | 320 |
321 BEGIN | 321 BEGIN |
322 | 322 |
323 STEP(10, "(printing fatal error message)") | 323 STEP(10, "(printing fatal error message)") |
324 | 324 |
325 st->print_cr("#"); | 325 st->print_cr("#"); |
326 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); | 326 if (should_report_bug(_id)) { |
327 st->print_cr("# A fatal error has been detected by the Java Runtime Environment:"); | |
328 } else { | |
329 st->print_cr("# There is insufficient memory for the Java " | |
330 "Runtime Environment to continue."); | |
331 } | |
327 | 332 |
328 STEP(15, "(printing type of error)") | 333 STEP(15, "(printing type of error)") |
329 | 334 |
330 switch(_id) { | 335 switch(_id) { |
331 case oom_error: | 336 case oom_error: |
332 st->print_cr("#"); | |
333 st->print("# java.lang.OutOfMemoryError: "); | |
334 if (_size) { | 337 if (_size) { |
335 st->print("requested "); | 338 st->print("# Native memory allocation (malloc) failed to allocate "); |
336 sprintf(buf,SIZE_FORMAT,_size); | 339 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size); |
337 st->print(buf); | 340 st->print(buf); |
338 st->print(" bytes"); | 341 st->print(" bytes"); |
339 if (_message != NULL) { | 342 if (_message != NULL) { |
340 st->print(" for "); | 343 st->print(" for "); |
341 st->print(_message); | 344 st->print(_message); |
342 } | 345 } |
343 st->print_cr(". Out of swap space?"); | 346 st->cr(); |
344 } else { | 347 } else { |
345 if (_message != NULL) | 348 if (_message != NULL) |
349 st->print("# "); | |
346 st->print_cr(_message); | 350 st->print_cr(_message); |
351 } | |
352 // In error file give some solutions | |
353 if (_verbose) { | |
354 st->print_cr("# Possible reasons:"); | |
355 st->print_cr("# The system is out of physical RAM or swap space"); | |
356 st->print_cr("# In 32 bit mode, the process size limit was hit"); | |
357 st->print_cr("# Possible solutions:"); | |
358 st->print_cr("# Reduce memory load on the system"); | |
359 st->print_cr("# Increase physical memory or swap space"); | |
360 st->print_cr("# Check if swap backing store is full"); | |
361 st->print_cr("# Use 64 bit Java on a 64 bit OS"); | |
362 st->print_cr("# Decrease Java heap size (-Xmx/-Xms)"); | |
363 st->print_cr("# Decrease number of Java threads"); | |
364 st->print_cr("# Decrease Java thread stack sizes (-Xss)"); | |
365 st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize="); | |
366 st->print_cr("# This output file may be truncated or incomplete."); | |
367 } else { | |
368 return; // that's enough for the screen | |
347 } | 369 } |
348 break; | 370 break; |
349 case internal_error: | 371 case internal_error: |
350 default: | 372 default: |
351 break; | 373 break; |
359 if (os::exception_name(_id, buf, sizeof(buf))) { | 381 if (os::exception_name(_id, buf, sizeof(buf))) { |
360 st->print("%s", buf); | 382 st->print("%s", buf); |
361 st->print(" (0x%x)", _id); // signal number | 383 st->print(" (0x%x)", _id); // signal number |
362 st->print(" at pc=" PTR_FORMAT, _pc); | 384 st->print(" at pc=" PTR_FORMAT, _pc); |
363 } else { | 385 } else { |
364 st->print("Internal Error"); | 386 if (should_report_bug(_id)) { |
387 st->print("Internal Error"); | |
388 } else { | |
389 st->print("Out of Memory Error"); | |
390 } | |
365 if (_filename != NULL && _lineno > 0) { | 391 if (_filename != NULL && _lineno > 0) { |
366 #ifdef PRODUCT | 392 #ifdef PRODUCT |
367 // In product mode chop off pathname? | 393 // In product mode chop off pathname? |
368 char separator = os::file_separator()[0]; | 394 char separator = os::file_separator()[0]; |
369 const char *p = strrchr(_filename, separator); | 395 const char *p = strrchr(_filename, separator); |
391 st->print(", tid=" UINTX_FORMAT, os::current_thread_id()); | 417 st->print(", tid=" UINTX_FORMAT, os::current_thread_id()); |
392 st->cr(); | 418 st->cr(); |
393 | 419 |
394 STEP(40, "(printing error message)") | 420 STEP(40, "(printing error message)") |
395 | 421 |
396 // error message | 422 if (should_report_bug(_id)) { // already printed the message. |
397 if (_detail_msg) { | 423 // error message |
398 st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); | 424 if (_detail_msg) { |
399 } else if (_message) { | 425 st->print_cr("# %s: %s", _message ? _message : "Error", _detail_msg); |
400 st->print_cr("# Error: %s", _message); | 426 } else if (_message) { |
401 } | 427 st->print_cr("# Error: %s", _message); |
428 } | |
429 } | |
402 | 430 |
403 STEP(50, "(printing Java version string)") | 431 STEP(50, "(printing Java version string)") |
404 | 432 |
405 // VM version | 433 // VM version |
406 st->print_cr("#"); | 434 st->print_cr("#"); |
426 st->print_cr("#"); | 454 st->print_cr("#"); |
427 } | 455 } |
428 | 456 |
429 STEP(65, "(printing bug submit message)") | 457 STEP(65, "(printing bug submit message)") |
430 | 458 |
431 if (_verbose) print_bug_submit_message(st, _thread); | 459 if (should_report_bug(_id) && _verbose) { |
460 print_bug_submit_message(st, _thread); | |
461 } | |
432 | 462 |
433 STEP(70, "(printing thread)" ) | 463 STEP(70, "(printing thread)" ) |
434 | 464 |
435 if (_verbose) { | 465 if (_verbose) { |
436 st->cr(); | 466 st->cr(); |
904 | 934 |
905 // done with OnError | 935 // done with OnError |
906 OnError = NULL; | 936 OnError = NULL; |
907 } | 937 } |
908 | 938 |
909 static bool skip_bug_url = false; | 939 static bool skip_bug_url = !should_report_bug(first_error->_id); |
910 if (!skip_bug_url) { | 940 if (!skip_bug_url) { |
911 skip_bug_url = true; | 941 skip_bug_url = true; |
912 | 942 |
913 out.print_raw_cr("#"); | 943 out.print_raw_cr("#"); |
914 print_bug_submit_message(&out, _thread); | 944 print_bug_submit_message(&out, _thread); |
917 if (!UseOSErrorReporting) { | 947 if (!UseOSErrorReporting) { |
918 // os::abort() will call abort hooks, try it first. | 948 // os::abort() will call abort hooks, try it first. |
919 static bool skip_os_abort = false; | 949 static bool skip_os_abort = false; |
920 if (!skip_os_abort) { | 950 if (!skip_os_abort) { |
921 skip_os_abort = true; | 951 skip_os_abort = true; |
922 os::abort(); | 952 bool dump_core = should_report_bug(first_error->_id); |
953 os::abort(dump_core); | |
923 } | 954 } |
924 | 955 |
925 // if os::abort() doesn't abort, try os::die(); | 956 // if os::abort() doesn't abort, try os::die(); |
926 os::die(); | 957 os::die(); |
927 } | 958 } |