提交 12d81084 编写于 作者: R roland

8029873: compiler/uncommontrap/TestStackBangRbp.java crashes with SIGSEGV

Summary: May end up in uncommon trap blob/deopt blob with unguarded stack
Reviewed-by: kvn, twisti
上级 9455f6a9
......@@ -1224,9 +1224,19 @@ void Deoptimization::load_class_by_index(constantPoolHandle constant_pool, int i
load_class_by_index(constant_pool, index, THREAD);
if (HAS_PENDING_EXCEPTION) {
// Exception happened during classloading. We ignore the exception here, since it
// is going to be rethrown since the current activation is going to be deoptimzied and
// is going to be rethrown since the current activation is going to be deoptimized and
// the interpreter will re-execute the bytecode.
CLEAR_PENDING_EXCEPTION;
// Class loading called java code which may have caused a stack
// overflow. If the exception was thrown right before the return
// to the runtime the stack is no longer guarded. Reguard the
// stack otherwise if we return to the uncommon trap blob and the
// stack bang causes a stack overflow we crash.
assert(THREAD->is_Java_thread(), "only a java thread can be here");
JavaThread* thread = (JavaThread*)THREAD;
bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
assert(guard_pages_enabled, "stack banging in uncommon trap blob may cause crash");
}
}
......
......@@ -494,6 +494,13 @@ address SharedRuntime::raw_exception_handler_for_return_address(JavaThread* thre
assert(!nm->is_native_method(), "no exception handler");
assert(nm->header_begin() != nm->exception_begin(), "no exception handler");
if (nm->is_deopt_pc(return_address)) {
// If we come here because of a stack overflow, the stack may be
// unguarded. Reguard the stack otherwise if we return to the
// deopt blob and the stack bang causes a stack overflow we
// crash.
bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
assert(guard_pages_enabled, "stack banging in deopt blob may cause crash");
return SharedRuntime::deopt_blob()->unpack_with_exception();
} else {
return nm->exception_begin();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册