384 }
385 }
386 }
387
388 if (thread->thread_state() == _thread_in_Java) {
389 // Java thread running in Java code => find exception handler if any
390 // a fault inside compiled code, the interpreter, or a stub
391
392 // A VM-related SIGILL may only occur if we are not in the zero page.
393 // On AIX, we get a SIGILL if we jump to 0x0 or to somewhere else
394 // in the zero page, because it is filled with 0x0. We ignore
395 // explicit SIGILLs in the zero page.
396 if (sig == SIGILL && (pc < (address) 0x200)) {
397 if (TraceTraps) {
398 tty->print_raw_cr("SIGILL happened inside zero page.");
399 }
400 goto report_and_die;
401 }
402
403 CodeBlob *cb = NULL;
404 // Handle signal from NativeJump::patch_verified_entry().
405 if (( TrapBasedNotEntrantChecks && sig == SIGTRAP && nativeInstruction_at(pc)->is_sigtrap_zombie_not_entrant()) ||
406 (!TrapBasedNotEntrantChecks && sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant())) {
407 if (TraceTraps) {
408 tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL");
409 }
410 stub = SharedRuntime::get_handle_wrong_method_stub();
411 }
412
413 else if ((sig == USE_POLL_BIT_ONLY ? SIGTRAP : SIGSEGV) &&
414 // A linux-ppc64 kernel before 2.6.6 doesn't set si_addr on some segfaults
415 // in 64bit mode (cf. http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.6),
416 // especially when we try to read from the safepoint polling page. So the check
417 // (address)info->si_addr == os::get_standard_polling_page()
418 // doesn't work for us. We use:
419 ((NativeInstruction*)pc)->is_safepoint_poll() &&
420 CodeCache::contains((void*) pc) &&
421 ((cb = CodeCache::find_blob(pc)) != NULL) &&
422 cb->is_compiled()) {
423 if (TraceTraps) {
424 tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (%s)", p2i(pc),
425 USE_POLL_BIT_ONLY ? "SIGTRAP" : "SIGSEGV");
426 }
427 stub = SharedRuntime::get_poll_stub(pc);
428 }
448 // SIGSEGV-based implicit null check in compiled code.
449 else if (sig == SIGSEGV && ImplicitNullChecks &&
450 CodeCache::contains((void*) pc) &&
451 MacroAssembler::uses_implicit_null_check(info->si_addr)) {
452 if (TraceTraps) {
453 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
454 }
455 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
456 }
457
458 #ifdef COMPILER2
459 // SIGTRAP-based implicit range check in compiled code.
460 else if (sig == SIGTRAP && TrapBasedRangeChecks &&
461 nativeInstruction_at(pc)->is_sigtrap_range_check()) {
462 if (TraceTraps) {
463 tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
464 }
465 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
466 }
467 #endif
468 else if (sig == SIGBUS) {
469 // BugId 4454115: A read from a MappedByteBuffer can fault here if the
470 // underlying file has been truncated. Do not crash the VM in such a case.
471 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
472 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
473 bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
474 if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
475 address next_pc = pc + 4;
476 if (is_unsafe_arraycopy) {
477 next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
478 }
479 next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
480 os::Linux::ucontext_set_pc(uc, next_pc);
481 return true;
482 }
483 }
484 }
485
486 else { // thread->thread_state() != _thread_in_Java
487 if (sig == SIGILL && VM_Version::is_determine_features_test_running()) {
|
384 }
385 }
386 }
387
388 if (thread->thread_state() == _thread_in_Java) {
389 // Java thread running in Java code => find exception handler if any
390 // a fault inside compiled code, the interpreter, or a stub
391
392 // A VM-related SIGILL may only occur if we are not in the zero page.
393 // On AIX, we get a SIGILL if we jump to 0x0 or to somewhere else
394 // in the zero page, because it is filled with 0x0. We ignore
395 // explicit SIGILLs in the zero page.
396 if (sig == SIGILL && (pc < (address) 0x200)) {
397 if (TraceTraps) {
398 tty->print_raw_cr("SIGILL happened inside zero page.");
399 }
400 goto report_and_die;
401 }
402
403 CodeBlob *cb = NULL;
404 int stop_type = -1;
405 // Handle signal from NativeJump::patch_verified_entry().
406 if (sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) {
407 if (TraceTraps) {
408 tty->print_cr("trap: zombie_not_entrant");
409 }
410 stub = SharedRuntime::get_handle_wrong_method_stub();
411 }
412
413 else if ((sig == USE_POLL_BIT_ONLY ? SIGTRAP : SIGSEGV) &&
414 // A linux-ppc64 kernel before 2.6.6 doesn't set si_addr on some segfaults
415 // in 64bit mode (cf. http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.6),
416 // especially when we try to read from the safepoint polling page. So the check
417 // (address)info->si_addr == os::get_standard_polling_page()
418 // doesn't work for us. We use:
419 ((NativeInstruction*)pc)->is_safepoint_poll() &&
420 CodeCache::contains((void*) pc) &&
421 ((cb = CodeCache::find_blob(pc)) != NULL) &&
422 cb->is_compiled()) {
423 if (TraceTraps) {
424 tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (%s)", p2i(pc),
425 USE_POLL_BIT_ONLY ? "SIGTRAP" : "SIGSEGV");
426 }
427 stub = SharedRuntime::get_poll_stub(pc);
428 }
448 // SIGSEGV-based implicit null check in compiled code.
449 else if (sig == SIGSEGV && ImplicitNullChecks &&
450 CodeCache::contains((void*) pc) &&
451 MacroAssembler::uses_implicit_null_check(info->si_addr)) {
452 if (TraceTraps) {
453 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
454 }
455 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
456 }
457
458 #ifdef COMPILER2
459 // SIGTRAP-based implicit range check in compiled code.
460 else if (sig == SIGTRAP && TrapBasedRangeChecks &&
461 nativeInstruction_at(pc)->is_sigtrap_range_check()) {
462 if (TraceTraps) {
463 tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", p2i(pc));
464 }
465 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
466 }
467 #endif
468
469 // stop on request
470 else if (sig == SIGTRAP && (stop_type = nativeInstruction_at(pc)->get_stop_type()) != -1) {
471 const char *msg = NULL,
472 *detail_msg = (const char*)(uc->uc_mcontext.regs->gpr[0]);
473 switch (stop_type) {
474 case MacroAssembler::stop_stop : msg = "stop"; break;
475 case MacroAssembler::stop_untested : msg = "untested"; break;
476 case MacroAssembler::stop_unimplemented : msg = "unimplemented"; break;
477 case MacroAssembler::stop_shouldnotreachhere: msg = "shouldnotreachhere"; detail_msg = NULL; break;
478 default: msg = "unknown"; break;
479 }
480 if (detail_msg == NULL) {
481 detail_msg = "no details provided";
482 }
483
484 if (TraceTraps) {
485 tty->print_cr("trap: %s: %s (SIGTRAP, stop type %d)", msg, detail_msg, stop_type);
486 }
487
488 va_list detail_args;
489 VMError::report_and_die(t, ucVoid, NULL, 0, msg, detail_msg, detail_args);
490 va_end(detail_args);
491 }
492
493 else if (sig == SIGBUS) {
494 // BugId 4454115: A read from a MappedByteBuffer can fault here if the
495 // underlying file has been truncated. Do not crash the VM in such a case.
496 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
497 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
498 bool is_unsafe_arraycopy = (thread->doing_unsafe_access() && UnsafeCopyMemory::contains_pc(pc));
499 if ((nm != NULL && nm->has_unsafe_access()) || is_unsafe_arraycopy) {
500 address next_pc = pc + 4;
501 if (is_unsafe_arraycopy) {
502 next_pc = UnsafeCopyMemory::page_error_continue_pc(pc);
503 }
504 next_pc = SharedRuntime::handle_unsafe_access(thread, next_pc);
505 os::Linux::ucontext_set_pc(uc, next_pc);
506 return true;
507 }
508 }
509 }
510
511 else { // thread->thread_state() != _thread_in_Java
512 if (sig == SIGILL && VM_Version::is_determine_features_test_running()) {
|