2549 // a result, we are out of here. |
2549 // a result, we are out of here. |
2550 fatal("ERROR: Unrecoverable stack overflow happened. JVM will exit."); |
2550 fatal("ERROR: Unrecoverable stack overflow happened. JVM will exit."); |
2551 } else if(thread->addr_inside_register_stack(addr)) { |
2551 } else if(thread->addr_inside_register_stack(addr)) { |
2552 // Disable the yellow zone which sets the state that |
2552 // Disable the yellow zone which sets the state that |
2553 // we've got a stack overflow problem. |
2553 // we've got a stack overflow problem. |
2554 if (thread->stack_yellow_zone_enabled()) { |
2554 if (thread->stack_yellow_reserved_zone_enabled()) { |
2555 thread->disable_stack_yellow_zone(); |
2555 thread->disable_stack_yellow_reserved_zone(); |
2556 } |
2556 } |
2557 // Give us some room to process the exception. |
2557 // Give us some room to process the exception. |
2558 thread->disable_register_stack_guard(); |
2558 thread->disable_register_stack_guard(); |
2559 // Tracing with +Verbose. |
2559 // Tracing with +Verbose. |
2560 if (Verbose) { |
2560 if (Verbose) { |
2585 } |
2585 } |
2586 } |
2586 } |
2587 // Yellow zone violation. The o/s has unprotected the first yellow |
2587 // Yellow zone violation. The o/s has unprotected the first yellow |
2588 // zone page for us. Note: must call disable_stack_yellow_zone to |
2588 // zone page for us. Note: must call disable_stack_yellow_zone to |
2589 // update the enabled status, even if the zone contains only one page. |
2589 // update the enabled status, even if the zone contains only one page. |
2590 thread->disable_stack_yellow_zone(); |
2590 thread->disable_stack_yellow_reserved_zone(); |
2591 // If not in java code, return and hope for the best. |
2591 // If not in java code, return and hope for the best. |
2592 return in_java |
2592 return in_java |
2593 ? Handle_Exception(exceptionInfo, SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW)) |
2593 ? Handle_Exception(exceptionInfo, SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW)) |
2594 : EXCEPTION_CONTINUE_EXECUTION; |
2594 : EXCEPTION_CONTINUE_EXECUTION; |
2595 } else { |
2595 } else { |
2614 } else if (exception_code == EXCEPTION_ACCESS_VIOLATION) { |
2614 } else if (exception_code == EXCEPTION_ACCESS_VIOLATION) { |
2615 // Either stack overflow or null pointer exception. |
2615 // Either stack overflow or null pointer exception. |
2616 if (in_java) { |
2616 if (in_java) { |
2617 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; |
2617 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; |
2618 address addr = (address) exceptionRecord->ExceptionInformation[1]; |
2618 address addr = (address) exceptionRecord->ExceptionInformation[1]; |
2619 address stack_end = thread->stack_base() - thread->stack_size(); |
2619 address stack_end = thread->stack_end(); |
2620 if (addr < stack_end && addr >= stack_end - os::vm_page_size()) { |
2620 if (addr < stack_end && addr >= stack_end - os::vm_page_size()) { |
2621 // Stack overflow. |
2621 // Stack overflow. |
2622 assert(!os::uses_stack_guard_pages(), |
2622 assert(!os::uses_stack_guard_pages(), |
2623 "should be caught by red zone code above."); |
2623 "should be caught by red zone code above."); |
2624 return Handle_Exception(exceptionInfo, |
2624 return Handle_Exception(exceptionInfo, |
2638 #ifdef _WIN64 |
2638 #ifdef _WIN64 |
2639 // If it's a legal stack address map the entire region in |
2639 // If it's a legal stack address map the entire region in |
2640 // |
2640 // |
2641 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; |
2641 PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; |
2642 address addr = (address) exceptionRecord->ExceptionInformation[1]; |
2642 address addr = (address) exceptionRecord->ExceptionInformation[1]; |
2643 if (addr > thread->stack_yellow_zone_base() && addr < thread->stack_base()) { |
2643 if (addr > thread->stack_reserved_zone_base() && addr < thread->stack_base()) { |
2644 addr = (address)((uintptr_t)addr & |
2644 addr = (address)((uintptr_t)addr & |
2645 (~((uintptr_t)os::vm_page_size() - (uintptr_t)1))); |
2645 (~((uintptr_t)os::vm_page_size() - (uintptr_t)1))); |
2646 os::commit_memory((char *)addr, thread->stack_base() - addr, |
2646 os::commit_memory((char *)addr, thread->stack_base() - addr, |
2647 !ExecMem); |
2647 !ExecMem); |
2648 return EXCEPTION_CONTINUE_EXECUTION; |
2648 return EXCEPTION_CONTINUE_EXECUTION; |
4183 // the java system classes, including StackOverflowError - depends on page |
4183 // the java system classes, including StackOverflowError - depends on page |
4184 // size. Add a page for compiler2 recursion in main thread. |
4184 // size. Add a page for compiler2 recursion in main thread. |
4185 // Add in 2*BytesPerWord times page size to account for VM stack during |
4185 // Add in 2*BytesPerWord times page size to account for VM stack during |
4186 // class initialization depending on 32 or 64 bit VM. |
4186 // class initialization depending on 32 or 64 bit VM. |
4187 size_t min_stack_allowed = |
4187 size_t min_stack_allowed = |
4188 (size_t)(StackYellowPages+StackRedPages+StackShadowPages+ |
4188 (size_t)(JavaThread::stack_yellow_zone_size() + JavaThread::stack_red_zone_size() + |
4189 2*BytesPerWord COMPILER2_PRESENT(+1)) * os::vm_page_size(); |
4189 JavaThread::stack_shadow_zone_size() + |
|
4190 (2*BytesPerWord COMPILER2_PRESENT(+1)) * os::vm_page_size()); |
4190 if (actual_reserve_size < min_stack_allowed) { |
4191 if (actual_reserve_size < min_stack_allowed) { |
4191 tty->print_cr("\nThe stack size specified is too small, " |
4192 tty->print_cr("\nThe stack size specified is too small, " |
4192 "Specify at least %dk", |
4193 "Specify at least %dk", |
4193 min_stack_allowed / K); |
4194 min_stack_allowed / K); |
4194 return JNI_ERR; |
4195 return JNI_ERR; |