1 /*
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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 *
287 for(int i = 0; !sfs.is_done(); sfs.next(), i++) {
288 sfs.current()->zero_print_on_error(i, st, buf, buflen);
289 st->cr();
290 }
291
292 // Reset the frame anchor if necessary
293 if (!has_last_Java_frame)
294 jt->reset_last_Java_frame();
295 }
296 #else
297 if (jt->has_last_Java_frame()) {
298 st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)");
299 for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) {
300 sfs.current()->print_on_error(st, buf, buflen, verbose);
301 st->cr();
302 }
303 }
304 #endif // ZERO
305 }
306
307 // This is the main function to report a fatal error. Only one thread can
308 // call this function, so we don't need to worry about MT-safety. But it's
309 // possible that the error handler itself may crash or die on an internal
310 // error, for example, when the stack/heap is badly damaged. We must be
311 // able to handle recursive errors that happen inside error handler.
312 //
313 // Error reporting is done in several steps. If a crash or internal error
314 // occurred when reporting an error, the nested signal/exception handler
315 // can skip steps that are already (or partially) done. Error reporting will
316 // continue from the next step. This allows us to retrieve and print
317 // information that may be unsafe to get after a fatal error. If it happens,
318 // you may find nested report_and_die() frames when you look at the stack
319 // in a debugger.
320 //
321 // In general, a hang in error handler is much worse than a crash or internal
322 // error, as it's harder to recover from a hang. Deadlock can happen if we
323 // try to grab a lock that is already owned by current thread, or if the
324 // owner is blocked forever (e.g. in os::infinite_sleep()). If possible, the
325 // error handler and all the functions it called should avoid grabbing any
326 // lock. An important thing to notice is that memory allocation needs a lock.
358 case OOM_MMAP_ERROR:
359 if (_size) {
360 st->print("# Native memory allocation ");
361 st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
362 "(mmap) failed to map ");
363 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
364 st->print("%s", buf);
365 st->print(" bytes");
366 if (_message != NULL) {
367 st->print(" for ");
368 st->print("%s", _message);
369 }
370 st->cr();
371 } else {
372 if (_message != NULL)
373 st->print("# ");
374 st->print_cr("%s", _message);
375 }
376 // In error file give some solutions
377 if (_verbose) {
378 st->print_cr("# Possible reasons:");
379 st->print_cr("# The system is out of physical RAM or swap space");
380 st->print_cr("# In 32 bit mode, the process size limit was hit");
381 st->print_cr("# Possible solutions:");
382 st->print_cr("# Reduce memory load on the system");
383 st->print_cr("# Increase physical memory or swap space");
384 st->print_cr("# Check if swap backing store is full");
385 st->print_cr("# Use 64 bit Java on a 64 bit OS");
386 st->print_cr("# Decrease Java heap size (-Xmx/-Xms)");
387 st->print_cr("# Decrease number of Java threads");
388 st->print_cr("# Decrease Java thread stack sizes (-Xss)");
389 st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize=");
390 st->print_cr("# This output file may be truncated or incomplete.");
391 } else {
392 return; // that's enough for the screen
393 }
394 break;
395 case INTERNAL_ERROR:
396 default:
397 break;
398 }
399
400 STEP(20, "(printing exception/signal name)")
401
402 st->print_cr("#");
403 st->print("# ");
404 // Is it an OS exception/signal?
405 if (os::exception_name(_id, buf, sizeof(buf))) {
406 st->print("%s", buf);
407 st->print(" (0x%x)", _id); // signal number
408 st->print(" at pc=" PTR_FORMAT, _pc);
409 } else {
410 if (should_report_bug(_id)) {
506 }
507
508 STEP(80, "(printing current thread)" )
509
510 // current thread
511 if (_verbose) {
512 if (_thread) {
513 st->print("Current thread (" PTR_FORMAT "): ", _thread);
514 _thread->print_on_error(st, buf, sizeof(buf));
515 st->cr();
516 } else {
517 st->print_cr("Current thread is native thread");
518 }
519 st->cr();
520 }
521
522 STEP(90, "(printing siginfo)" )
523
524 // signal no, signal code, address that caused the fault
525 if (_verbose && _siginfo) {
526 os::print_siginfo(st, _siginfo);
527 st->cr();
528 }
529
530 STEP(100, "(printing registers, top of stack, instructions near pc)")
531
532 // registers, top of stack, instructions near pc
533 if (_verbose && _context) {
534 os::print_context(st, _context);
535 st->cr();
536 }
537
538 STEP(105, "(printing register info)")
539
540 // decode register contents if possible
541 if (_verbose && _context && Universe::is_fully_initialized()) {
542 os::print_register_info(st, _context);
543 st->cr();
544 }
545
|
1 /*
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
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 *
287 for(int i = 0; !sfs.is_done(); sfs.next(), i++) {
288 sfs.current()->zero_print_on_error(i, st, buf, buflen);
289 st->cr();
290 }
291
292 // Reset the frame anchor if necessary
293 if (!has_last_Java_frame)
294 jt->reset_last_Java_frame();
295 }
296 #else
297 if (jt->has_last_Java_frame()) {
298 st->print_cr("Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)");
299 for(StackFrameStream sfs(jt); !sfs.is_done(); sfs.next()) {
300 sfs.current()->print_on_error(st, buf, buflen, verbose);
301 st->cr();
302 }
303 }
304 #endif // ZERO
305 }
306
307 static void print_oom_reasons(outputStream* st) {
308 st->print_cr("# Possible reasons:");
309 st->print_cr("# The system is out of physical RAM or swap space");
310 if (UseCompressedOops) {
311 st->print_cr("# The process is running with CompressedOops enabled, and the Java Heap may be blocking the growth of the native heap");
312 }
313 if (LogBytesPerWord == 2) {
314 st->print_cr("# In 32 bit mode, the process size limit was hit");
315 }
316 st->print_cr("# Possible solutions:");
317 st->print_cr("# Reduce memory load on the system");
318 st->print_cr("# Increase physical memory or swap space");
319 st->print_cr("# Check if swap backing store is full");
320 if (LogBytesPerWord == 2) {
321 st->print_cr("# Use 64 bit Java on a 64 bit OS");
322 }
323 st->print_cr("# Decrease Java heap size (-Xmx/-Xms)");
324 st->print_cr("# Decrease number of Java threads");
325 st->print_cr("# Decrease Java thread stack sizes (-Xss)");
326 st->print_cr("# Set larger code cache with -XX:ReservedCodeCacheSize=");
327 if (UseCompressedOops) {
328 switch (Universe::narrow_oop_mode()) {
329 case Universe::UnscaledNarrowOop:
330 st->print_cr("# JVM is running with Unscaled Compressed Oops mode in which the Java heap is");
331 st->print_cr("# placed in the first 4GB address space. The Java Heap base address is the");
332 st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress");
333 st->print_cr("# to set the Java Heap base and to place the Java Heap above 4GB virtual address.");
334 break;
335 case Universe::ZeroBasedNarrowOop:
336 st->print_cr("# JVM is running with Zero Based Compressed Oops mode in which the Java heap is");
337 st->print_cr("# placed in the first 32GB address space. The Java Heap base address is the");
338 st->print_cr("# maximum limit for the native heap growth. Please use -XX:HeapBaseMinAddress");
339 st->print_cr("# to set the Java Heap base and to place the Java Heap above 32GB virtual address.");
340 break;
341 default:
342 break;
343 }
344 }
345 st->print_cr("# This output file may be truncated or incomplete.");
346 }
347 // This is the main function to report a fatal error. Only one thread can
348 // call this function, so we don't need to worry about MT-safety. But it's
349 // possible that the error handler itself may crash or die on an internal
350 // error, for example, when the stack/heap is badly damaged. We must be
351 // able to handle recursive errors that happen inside error handler.
352 //
353 // Error reporting is done in several steps. If a crash or internal error
354 // occurred when reporting an error, the nested signal/exception handler
355 // can skip steps that are already (or partially) done. Error reporting will
356 // continue from the next step. This allows us to retrieve and print
357 // information that may be unsafe to get after a fatal error. If it happens,
358 // you may find nested report_and_die() frames when you look at the stack
359 // in a debugger.
360 //
361 // In general, a hang in error handler is much worse than a crash or internal
362 // error, as it's harder to recover from a hang. Deadlock can happen if we
363 // try to grab a lock that is already owned by current thread, or if the
364 // owner is blocked forever (e.g. in os::infinite_sleep()). If possible, the
365 // error handler and all the functions it called should avoid grabbing any
366 // lock. An important thing to notice is that memory allocation needs a lock.
398 case OOM_MMAP_ERROR:
399 if (_size) {
400 st->print("# Native memory allocation ");
401 st->print((_id == (int)OOM_MALLOC_ERROR) ? "(malloc) failed to allocate " :
402 "(mmap) failed to map ");
403 jio_snprintf(buf, sizeof(buf), SIZE_FORMAT, _size);
404 st->print("%s", buf);
405 st->print(" bytes");
406 if (_message != NULL) {
407 st->print(" for ");
408 st->print("%s", _message);
409 }
410 st->cr();
411 } else {
412 if (_message != NULL)
413 st->print("# ");
414 st->print_cr("%s", _message);
415 }
416 // In error file give some solutions
417 if (_verbose) {
418 print_oom_reasons(st);
419 } else {
420 return; // that's enough for the screen
421 }
422 break;
423 case INTERNAL_ERROR:
424 default:
425 break;
426 }
427
428 STEP(20, "(printing exception/signal name)")
429
430 st->print_cr("#");
431 st->print("# ");
432 // Is it an OS exception/signal?
433 if (os::exception_name(_id, buf, sizeof(buf))) {
434 st->print("%s", buf);
435 st->print(" (0x%x)", _id); // signal number
436 st->print(" at pc=" PTR_FORMAT, _pc);
437 } else {
438 if (should_report_bug(_id)) {
534 }
535
536 STEP(80, "(printing current thread)" )
537
538 // current thread
539 if (_verbose) {
540 if (_thread) {
541 st->print("Current thread (" PTR_FORMAT "): ", _thread);
542 _thread->print_on_error(st, buf, sizeof(buf));
543 st->cr();
544 } else {
545 st->print_cr("Current thread is native thread");
546 }
547 st->cr();
548 }
549
550 STEP(90, "(printing siginfo)" )
551
552 // signal no, signal code, address that caused the fault
553 if (_verbose && _siginfo) {
554 st->cr();
555 os::print_siginfo(st, _siginfo);
556 st->cr();
557 }
558
559 STEP(100, "(printing registers, top of stack, instructions near pc)")
560
561 // registers, top of stack, instructions near pc
562 if (_verbose && _context) {
563 os::print_context(st, _context);
564 st->cr();
565 }
566
567 STEP(105, "(printing register info)")
568
569 // decode register contents if possible
570 if (_verbose && _context && Universe::is_fully_initialized()) {
571 os::print_register_info(st, _context);
572 st->cr();
573 }
574
|