# HG changeset patch # User fparain # Date 1473267140 14400 # Node ID 2fd1cf3e70e98f196454c8ad27326dc7a9ba9c1b # Parent 04b19236aa980d57dc2a98cb1164c31122bea0f5 8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit Reviewed-by: dholmes, dcubed, coleenp diff -r 04b19236aa98 -r 2fd1cf3e70e9 hotspot/src/cpu/x86/vm/globals_x86.hpp --- a/hotspot/src/cpu/x86/vm/globals_x86.hpp Wed Sep 07 15:21:45 2016 +0200 +++ b/hotspot/src/cpu/x86/vm/globals_x86.hpp Wed Sep 07 12:52:20 2016 -0400 @@ -65,10 +65,10 @@ #ifdef AMD64 // Very large C++ stack frames using solaris-amd64 optimized builds // due to lack of optimization caused by C++ compiler bugs -#define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(6) DEBUG_ONLY(+2)) +#define DEFAULT_STACK_SHADOW_PAGES (NOT_WIN64(20) WIN64_ONLY(7) DEBUG_ONLY(+2)) // For those clients that do not use write socket, we allow // the min range value to be below that of the default -#define MIN_STACK_SHADOW_PAGES (NOT_WIN64(10) WIN64_ONLY(6) DEBUG_ONLY(+2)) +#define MIN_STACK_SHADOW_PAGES (NOT_WIN64(10) WIN64_ONLY(7) DEBUG_ONLY(+2)) #else #define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5)) #define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES diff -r 04b19236aa98 -r 2fd1cf3e70e9 hotspot/src/os/windows/vm/os_windows.cpp --- a/hotspot/src/os/windows/vm/os_windows.cpp Wed Sep 07 15:21:45 2016 +0200 +++ b/hotspot/src/os/windows/vm/os_windows.cpp Wed Sep 07 12:52:20 2016 -0400 @@ -2504,13 +2504,15 @@ // It write enables the page immediately after protecting it // so just return. if (exception_code == EXCEPTION_ACCESS_VIOLATION) { - JavaThread* thread = (JavaThread*) t; - PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; - address addr = (address) exceptionRecord->ExceptionInformation[1]; - if (os::is_memory_serialize_page(thread, addr)) { - // Block current thread until the memory serialize page permission restored. - os::block_on_serialize_page_trap(); - return EXCEPTION_CONTINUE_EXECUTION; + if (t != NULL && t->is_Java_thread()) { + JavaThread* thread = (JavaThread*) t; + PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; + address addr = (address) exceptionRecord->ExceptionInformation[1]; + if (os::is_memory_serialize_page(thread, addr)) { + // Block current thread until the memory serialize page permission restored. + os::block_on_serialize_page_trap(); + return EXCEPTION_CONTINUE_EXECUTION; + } } } @@ -2564,7 +2566,7 @@ } #endif if (thread->stack_guards_enabled()) { - if (_thread_in_Java) { + if (in_java) { frame fr; PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; address addr = (address) exceptionRecord->ExceptionInformation[1]; @@ -2576,6 +2578,7 @@ // Yellow zone violation. The o/s has unprotected the first yellow // zone page for us. Note: must call disable_stack_yellow_zone to // update the enabled status, even if the zone contains only one page. + assert(thread->thread_state() != _thread_in_vm, "Undersized StackShadowPages"); thread->disable_stack_yellow_reserved_zone(); // If not in java code, return and hope for the best. return in_java diff -r 04b19236aa98 -r 2fd1cf3e70e9 hotspot/src/share/vm/runtime/interfaceSupport.hpp --- a/hotspot/src/share/vm/runtime/interfaceSupport.hpp Wed Sep 07 15:21:45 2016 +0200 +++ b/hotspot/src/share/vm/runtime/interfaceSupport.hpp Wed Sep 07 12:52:20 2016 -0400 @@ -219,6 +219,9 @@ trans_from_java(_thread_in_vm); } ~ThreadInVMfromJava() { + if (_thread->stack_yellow_reserved_zone_disabled()) { + _thread->enable_stack_yellow_reserved_zone(); + } trans(_thread_in_vm, _thread_in_Java); // Check for pending. async. exceptions or suspends. if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(); @@ -306,6 +309,9 @@ trans_from_java(_thread_in_vm); } ~ThreadInVMfromJavaNoAsyncException() { + if (_thread->stack_yellow_reserved_zone_disabled()) { + _thread->enable_stack_yellow_reserved_zone(); + } trans(_thread_in_vm, _thread_in_Java); // NOTE: We do not check for pending. async. exceptions. // If we did and moved the pending async exception over into the @@ -314,6 +320,7 @@ // to the _thread_in_vm state. Instead we postpone the handling of // the async exception. + // Check for pending. suspends only. if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(false);