364 if (TraceTraps) {
365 tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL");
366 }
367 stub = SharedRuntime::get_handle_wrong_method_stub();
368 } else if (sig == SIGSEGV && SafepointMechanism::is_poll_address((address)info->si_addr)) {
369 stub = SharedRuntime::get_poll_stub(pc);
370 } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
371 // BugId 4454115: A read from a MappedByteBuffer can fault
372 // here if the underlying file has been truncated.
373 // Do not crash the VM in such a case.
374 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
375 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
376 bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
377 if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
378 address next_pc = pc + NativeCall::instruction_size;
379 if (is_unsafe_arraycopy) {
380 next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
381 }
382 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
383 }
384 }
385 else
386
387 if (sig == SIGFPE &&
388 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
389 stub =
390 SharedRuntime::
391 continuation_for_implicit_exception(thread,
392 pc,
393 SharedRuntime::
394 IMPLICIT_DIVIDE_BY_ZERO);
395 } else if (sig == SIGSEGV &&
396 MacroAssembler::uses_implicit_null_check((void*)addr)) {
397 // Determination of interpreter/vtable stub/compiled code null exception
398 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
399 }
400 } else if ((thread->thread_state() == _thread_in_vm ||
401 thread->thread_state() == _thread_in_native) &&
402 sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
403 thread->doing_unsafe_access()) {
488 void os::print_context(outputStream *st, const void *context) {
489 if (context == NULL) return;
490
491 const ucontext_t *uc = (const ucontext_t*)context;
492 st->print_cr("Registers:");
493 for (int r = 0; r < 31; r++) {
494 st->print("R%-2d=", r);
495 print_location(st, uc->uc_mcontext.regs[r]);
496 }
497 st->cr();
498
499 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
500 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
501 print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
502 st->cr();
503
504 // Note: it may be unsafe to inspect memory near pc. For example, pc may
505 // point to garbage if entry point in an nmethod is corrupted. Leave
506 // this at the end, and hope for the best.
507 address pc = os::Linux::ucontext_get_pc(uc);
508 print_instructions(st, pc, sizeof(char));
509 st->cr();
510 }
511
512 void os::print_register_info(outputStream *st, const void *context) {
513 if (context == NULL) return;
514
515 const ucontext_t *uc = (const ucontext_t*)context;
516
517 st->print_cr("Register to memory mapping:");
518 st->cr();
519
520 // this is horrendously verbose but the layout of the registers in the
521 // context does not match how we defined our abstract Register set, so
522 // we can't just iterate through the gregs area
523
524 // this is only for the "general purpose" registers
525
526 for (int r = 0; r < 31; r++)
527 st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]);
528 st->cr();
|
364 if (TraceTraps) {
365 tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL");
366 }
367 stub = SharedRuntime::get_handle_wrong_method_stub();
368 } else if (sig == SIGSEGV && SafepointMechanism::is_poll_address((address)info->si_addr)) {
369 stub = SharedRuntime::get_poll_stub(pc);
370 } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
371 // BugId 4454115: A read from a MappedByteBuffer can fault
372 // here if the underlying file has been truncated.
373 // Do not crash the VM in such a case.
374 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
375 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
376 bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
377 if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
378 address next_pc = pc + NativeCall::instruction_size;
379 if (is_unsafe_arraycopy) {
380 next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
381 }
382 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
383 }
384 } else if (sig == SIGILL && nativeInstruction_at(pc)->is_stop()) {
385 // Pull a pointer to the error message out of the instruction
386 // stream.
387 const uint64_t *detail_msg_ptr
388 = (uint64_t*)(pc + NativeInstruction::instruction_size);
389 const char *detail_msg = (const char *)*detail_msg_ptr;
390 const char *msg = "stop";
391 if (TraceTraps) {
392 tty->print_cr("trap: %s: (SIGILL)", msg);
393 }
394
395 va_list detail_args;
396 VMError::report_and_die(INTERNAL_ERROR, msg, detail_msg, detail_args, thread,
397 pc, info, ucVoid, NULL, 0, 0);
398 va_end(detail_args);
399 }
400 else
401
402 if (sig == SIGFPE &&
403 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
404 stub =
405 SharedRuntime::
406 continuation_for_implicit_exception(thread,
407 pc,
408 SharedRuntime::
409 IMPLICIT_DIVIDE_BY_ZERO);
410 } else if (sig == SIGSEGV &&
411 MacroAssembler::uses_implicit_null_check((void*)addr)) {
412 // Determination of interpreter/vtable stub/compiled code null exception
413 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
414 }
415 } else if ((thread->thread_state() == _thread_in_vm ||
416 thread->thread_state() == _thread_in_native) &&
417 sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
418 thread->doing_unsafe_access()) {
503 void os::print_context(outputStream *st, const void *context) {
504 if (context == NULL) return;
505
506 const ucontext_t *uc = (const ucontext_t*)context;
507 st->print_cr("Registers:");
508 for (int r = 0; r < 31; r++) {
509 st->print("R%-2d=", r);
510 print_location(st, uc->uc_mcontext.regs[r]);
511 }
512 st->cr();
513
514 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc);
515 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp));
516 print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t));
517 st->cr();
518
519 // Note: it may be unsafe to inspect memory near pc. For example, pc may
520 // point to garbage if entry point in an nmethod is corrupted. Leave
521 // this at the end, and hope for the best.
522 address pc = os::Linux::ucontext_get_pc(uc);
523 print_instructions(st, pc, 4/*native instruction size*/);
524 st->cr();
525 }
526
527 void os::print_register_info(outputStream *st, const void *context) {
528 if (context == NULL) return;
529
530 const ucontext_t *uc = (const ucontext_t*)context;
531
532 st->print_cr("Register to memory mapping:");
533 st->cr();
534
535 // this is horrendously verbose but the layout of the registers in the
536 // context does not match how we defined our abstract Register set, so
537 // we can't just iterate through the gregs area
538
539 // this is only for the "general purpose" registers
540
541 for (int r = 0; r < 31; r++)
542 st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]);
543 st->cr();
|