src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp

Print this page
rev 3324 : 7167254: Crash on OSX in Enumerator.nextElement() with compressed oops
Summary: null checks in "compressed oops with base" mode may trigger a SIGBUS rather than a SIGSEGV.
Reviewed-by:


 505              thread->osthread()->set_expanding_stack();
 506              if (os::Bsd::manually_expand_stack(thread, addr)) {
 507                thread->osthread()->clear_expanding_stack();
 508                return 1;
 509              }
 510              thread->osthread()->clear_expanding_stack();
 511           } else {
 512              fatal("recursive segv. expanding stack.");
 513           }
 514 #endif
 515         }
 516       }
 517     }
 518 
 519     if (thread->thread_state() == _thread_in_Java) {
 520       // Java thread running in Java code => find exception handler if any
 521       // a fault inside compiled code, the interpreter, or a stub
 522 
 523       if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {
 524         stub = SharedRuntime::get_poll_stub(pc);
 525 #if defined(__APPLE__) && !defined(AMD64)
 526       // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
 527       // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
 528       // being called, so only do so if the implicit NULL check is not necessary.
 529       } else if (sig == SIGBUS && MacroAssembler::needs_explicit_null_check((int)info->si_addr)) {
 530 #else
 531       } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
 532 #endif
 533         // BugId 4454115: A read from a MappedByteBuffer can fault
 534         // here if the underlying file has been truncated.
 535         // Do not crash the VM in such a case.
 536         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
 537         nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
 538         if (nm != NULL && nm->has_unsafe_access()) {
 539           stub = StubRoutines::handler_for_unsafe_access();
 540         }
 541       }
 542       else
 543 
 544 #ifdef AMD64
 545       if (sig == SIGFPE  &&




 505              thread->osthread()->set_expanding_stack();
 506              if (os::Bsd::manually_expand_stack(thread, addr)) {
 507                thread->osthread()->clear_expanding_stack();
 508                return 1;
 509              }
 510              thread->osthread()->clear_expanding_stack();
 511           } else {
 512              fatal("recursive segv. expanding stack.");
 513           }
 514 #endif
 515         }
 516       }
 517     }
 518 
 519     if (thread->thread_state() == _thread_in_Java) {
 520       // Java thread running in Java code => find exception handler if any
 521       // a fault inside compiled code, the interpreter, or a stub
 522 
 523       if ((sig == SIGSEGV || sig == SIGBUS) && os::is_poll_address((address)info->si_addr)) {
 524         stub = SharedRuntime::get_poll_stub(pc);
 525 #if defined(__APPLE__)
 526       // 32-bit Darwin reports a SIGBUS for nearly all memory access exceptions.
 527       // Catching SIGBUS here prevents the implicit SIGBUS NULL check below from
 528       // being called, so only do so if the implicit NULL check is not necessary.
 529       } else if (sig == SIGBUS && MacroAssembler::needs_explicit_null_check((int)info->si_addr)) {
 530 #else
 531       } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) {
 532 #endif
 533         // BugId 4454115: A read from a MappedByteBuffer can fault
 534         // here if the underlying file has been truncated.
 535         // Do not crash the VM in such a case.
 536         CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
 537         nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL;
 538         if (nm != NULL && nm->has_unsafe_access()) {
 539           stub = StubRoutines::handler_for_unsafe_access();
 540         }
 541       }
 542       else
 543 
 544 #ifdef AMD64
 545       if (sig == SIGFPE  &&