switch(thr_type){caseos::java_thread:// Java threads use ThreadStackSize which default value can be// changed with the flag -Xssassert(JavaThread::stack_size_at_create()>0,"this should be set");stack_size=JavaThread::stack_size_at_create();break;caseos::compiler_thread:if(CompilerThreadStackSize>0){stack_size=(size_t)(CompilerThreadStackSize*K);break;}// else fall through:// use VMThreadStackSize if CompilerThreadStackSize is not definedcaseos::vm_thread:caseos::pgc_thread:caseos::cgc_thread:caseos::watcher_thread:if(VMThreadStackSize>0)stack_size=(size_t)(VMThreadStackSize*K);break;}
if(sig==SIGSEGV){addressaddr=(address)info->si_addr;// check if fault address is within thread stackif(addr<thread->stack_base()&&addr>=thread->stack_base()-thread->stack_size()){// stack overflowif(thread->in_stack_yellow_zone(addr)){thread->disable_stack_yellow_zone();if(thread->thread_state()==_thread_in_Java){// Throw a stack overflow exception. Guard pages will be reenabled// while unwinding the stack.stub=SharedRuntime::continuation_for_implicit_exception(thread,pc,SharedRuntime::STACK_OVERFLOW);}else{// Thread was in the vm or native code. Return and try to finish.return1;}}elseif(thread->in_stack_red_zone(addr)){// Fatal red zone violation. Disable the guard pages and fall through// to handle_unexpected_exception way down below.thread->disable_stack_red_zone();tty->print_raw_cr("An irrecoverable stack overflow has occurred.");// This is a likely cause, but hard to verify. Let's just print// it as a hint.tty->print_raw_cr("Please check if any of your loaded .so files has ""enabled executable stack (see man page execstack(8))");}else{// Accessing stack address below sp may cause SEGV if current// thread has MAP_GROWSDOWN stack. This should only happen when// current thread was created by user code with MAP_GROWSDOWN flag// and then attached to VM. See notes in os_linux.cpp.if(thread->osthread()->expanding_stack()==0){thread->osthread()->set_expanding_stack();if(os::Linux::manually_expand_stack(thread,addr)){thread->osthread()->clear_expanding_stack();return1;}thread->osthread()->clear_expanding_stack();}else{fatal("recursive segv. expanding stack.");}}}}......if(stub!=NULL){// save all thread context in case we need to restore itif(thread!=NULL)thread->set_saved_exception_pc(pc);uc->uc_mcontext.gregs[REG_PC]=(greg_t)stub;returntrue;}// signal-chainingif(os::Linux::chained_handler(sig,info,ucVoid)){returntrue;}if(!abort_if_unrecognized){// caller wants another chance, so give it to himreturnfalse;}if(pc==NULL&&uc!=NULL){pc=os::Linux::ucontext_get_pc(uc);}// unmask current signalsigset_tnewset;sigemptyset(&newset);sigaddset(&newset,sig);sigprocmask(SIG_UNBLOCK,&newset,NULL);VMErrorerr(t,sig,pc,info,ucVoid);err.report_and_die();ShouldNotReachHere();