8137035: nsk/stress/stack/stack tests got EXCEPTION_STACK_OVERFLOW on Windows 64 bit

Reviewed-by: dholmes, dcubed, coleenp
This commit is contained in:
Frederic Parain 2016-09-07 12:52:20 -04:00
parent be0d2c98ed
commit a900715bbf
3 changed files with 20 additions and 10 deletions

View file

@ -65,10 +65,10 @@ define_pd_global(intx, InlineSmallCode, 1000);
#ifdef AMD64 #ifdef AMD64
// Very large C++ stack frames using solaris-amd64 optimized builds // Very large C++ stack frames using solaris-amd64 optimized builds
// due to lack of optimization caused by C++ compiler bugs // 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 // For those clients that do not use write socket, we allow
// the min range value to be below that of the default // 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 #else
#define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5)) #define DEFAULT_STACK_SHADOW_PAGES (4 DEBUG_ONLY(+5))
#define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES #define MIN_STACK_SHADOW_PAGES DEFAULT_STACK_SHADOW_PAGES

View file

@ -2504,6 +2504,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
// It write enables the page immediately after protecting it // It write enables the page immediately after protecting it
// so just return. // so just return.
if (exception_code == EXCEPTION_ACCESS_VIOLATION) { if (exception_code == EXCEPTION_ACCESS_VIOLATION) {
if (t != NULL && t->is_Java_thread()) {
JavaThread* thread = (JavaThread*) t; JavaThread* thread = (JavaThread*) t;
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
address addr = (address) exceptionRecord->ExceptionInformation[1]; address addr = (address) exceptionRecord->ExceptionInformation[1];
@ -2513,6 +2514,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
return EXCEPTION_CONTINUE_EXECUTION; return EXCEPTION_CONTINUE_EXECUTION;
} }
} }
}
if ((exception_code == EXCEPTION_ACCESS_VIOLATION) && if ((exception_code == EXCEPTION_ACCESS_VIOLATION) &&
VM_Version::is_cpuinfo_segv_addr(pc)) { VM_Version::is_cpuinfo_segv_addr(pc)) {
@ -2564,7 +2566,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
} }
#endif #endif
if (thread->stack_guards_enabled()) { if (thread->stack_guards_enabled()) {
if (_thread_in_Java) { if (in_java) {
frame fr; frame fr;
PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord; PEXCEPTION_RECORD exceptionRecord = exceptionInfo->ExceptionRecord;
address addr = (address) exceptionRecord->ExceptionInformation[1]; address addr = (address) exceptionRecord->ExceptionInformation[1];
@ -2576,6 +2578,7 @@ LONG WINAPI topLevelExceptionFilter(struct _EXCEPTION_POINTERS* exceptionInfo) {
// Yellow zone violation. The o/s has unprotected the first yellow // Yellow zone violation. The o/s has unprotected the first yellow
// zone page for us. Note: must call disable_stack_yellow_zone to // zone page for us. Note: must call disable_stack_yellow_zone to
// update the enabled status, even if the zone contains only one page. // 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(); thread->disable_stack_yellow_reserved_zone();
// If not in java code, return and hope for the best. // If not in java code, return and hope for the best.
return in_java return in_java

View file

@ -219,6 +219,9 @@ class ThreadInVMfromJava : public ThreadStateTransition {
trans_from_java(_thread_in_vm); trans_from_java(_thread_in_vm);
} }
~ThreadInVMfromJava() { ~ThreadInVMfromJava() {
if (_thread->stack_yellow_reserved_zone_disabled()) {
_thread->enable_stack_yellow_reserved_zone();
}
trans(_thread_in_vm, _thread_in_Java); trans(_thread_in_vm, _thread_in_Java);
// Check for pending. async. exceptions or suspends. // Check for pending. async. exceptions or suspends.
if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition(); if (_thread->has_special_runtime_exit_condition()) _thread->handle_special_runtime_exit_condition();
@ -306,6 +309,9 @@ class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition {
trans_from_java(_thread_in_vm); trans_from_java(_thread_in_vm);
} }
~ThreadInVMfromJavaNoAsyncException() { ~ThreadInVMfromJavaNoAsyncException() {
if (_thread->stack_yellow_reserved_zone_disabled()) {
_thread->enable_stack_yellow_reserved_zone();
}
trans(_thread_in_vm, _thread_in_Java); trans(_thread_in_vm, _thread_in_Java);
// NOTE: We do not check for pending. async. exceptions. // NOTE: We do not check for pending. async. exceptions.
// If we did and moved the pending async exception over into the // If we did and moved the pending async exception over into the
@ -314,6 +320,7 @@ class ThreadInVMfromJavaNoAsyncException : public ThreadStateTransition {
// to the _thread_in_vm state. Instead we postpone the handling of // to the _thread_in_vm state. Instead we postpone the handling of
// the async exception. // the async exception.
// Check for pending. suspends only. // Check for pending. suspends only.
if (_thread->has_special_runtime_exit_condition()) if (_thread->has_special_runtime_exit_condition())
_thread->handle_special_runtime_exit_condition(false); _thread->handle_special_runtime_exit_condition(false);