提交 a0c766aa 编写于 作者: N never

7088020: SEGV in JNIHandleBlock::release_block

Reviewed-by: kvn, twisti
上级 c883147f
...@@ -436,7 +436,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -436,7 +436,7 @@ class StubGenerator: public StubCodeGenerator {
#undef __ #undef __
#define __ masm-> #define __ masm->
address generate_throw_exception(const char* name, address runtime_entry, bool restore_saved_exception_pc, address generate_throw_exception(const char* name, address runtime_entry,
Register arg1 = noreg, Register arg2 = noreg) { Register arg1 = noreg, Register arg2 = noreg) {
#ifdef ASSERT #ifdef ASSERT
int insts_size = VerifyThread ? 1 * K : 600; int insts_size = VerifyThread ? 1 * K : 600;
...@@ -462,11 +462,6 @@ class StubGenerator: public StubCodeGenerator { ...@@ -462,11 +462,6 @@ class StubGenerator: public StubCodeGenerator {
int frame_complete = __ offset(); int frame_complete = __ offset();
if (restore_saved_exception_pc) {
__ ld_ptr(G2_thread, JavaThread::saved_exception_pc_offset(), I7);
__ sub(I7, frame::pc_return_offset, I7);
}
// Note that we always have a runtime stub frame on the top of stack by this point // Note that we always have a runtime stub frame on the top of stack by this point
Register last_java_sp = SP; Register last_java_sp = SP;
// 64-bit last_java_sp is biased! // 64-bit last_java_sp is biased!
...@@ -3418,7 +3413,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -3418,7 +3413,7 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_throw_WrongMethodTypeException_entry = StubRoutines::_throw_WrongMethodTypeException_entry =
generate_throw_exception("WrongMethodTypeException throw_exception", generate_throw_exception("WrongMethodTypeException throw_exception",
CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException), CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException),
false, G5_method_type, G3_method_handle); G5_method_type, G3_method_handle);
} }
...@@ -3429,12 +3424,10 @@ class StubGenerator: public StubCodeGenerator { ...@@ -3429,12 +3424,10 @@ class StubGenerator: public StubCodeGenerator {
// UseZeroBaseCompressedOops which is defined after heap initialization. // UseZeroBaseCompressedOops which is defined after heap initialization.
StubRoutines::Sparc::_partial_subtype_check = generate_partial_subtype_check(); StubRoutines::Sparc::_partial_subtype_check = generate_partial_subtype_check();
// These entry points require SharedInfo::stack0 to be set up in non-core builds // These entry points require SharedInfo::stack0 to be set up in non-core builds
StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError), false); StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false); StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
StubRoutines::_throw_ArithmeticException_entry = generate_throw_exception("ArithmeticException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_ArithmeticException), true); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
StubRoutines::_throw_NullPointerException_entry = generate_throw_exception("NullPointerException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException), true); StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
StubRoutines::_handler_for_unsafe_access_entry = StubRoutines::_handler_for_unsafe_access_entry =
generate_handler_for_unsafe_access(); generate_handler_for_unsafe_access();
......
...@@ -624,6 +624,11 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* ...@@ -624,6 +624,11 @@ address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler*
// error path for invokeExact (only) // error path for invokeExact (only)
__ bind(invoke_exact_error_path); __ bind(invoke_exact_error_path);
// ensure that the top of stack is properly aligned.
__ mov(rdi, rsp);
__ andptr(rsp, -StackAlignmentInBytes); // Align the stack for the ABI
__ pushptr(Address(rdi, 0)); // Pick up the return address
// Stub wants expected type in rax and the actual type in rcx // Stub wants expected type in rax and the actual type in rcx
__ jump(ExternalAddress(StubRoutines::throw_WrongMethodTypeException_entry())); __ jump(ExternalAddress(StubRoutines::throw_WrongMethodTypeException_entry()));
......
...@@ -2187,7 +2187,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2187,7 +2187,7 @@ class StubGenerator: public StubCodeGenerator {
// either at call sites or otherwise assume that stack unwinding will be initiated, // either at call sites or otherwise assume that stack unwinding will be initiated,
// so caller saved registers were assumed volatile in the compiler. // so caller saved registers were assumed volatile in the compiler.
address generate_throw_exception(const char* name, address runtime_entry, address generate_throw_exception(const char* name, address runtime_entry,
bool restore_saved_exception_pc, Register arg1 = noreg, Register arg2 = noreg) { Register arg1 = noreg, Register arg2 = noreg) {
int insts_size = 256; int insts_size = 256;
int locs_size = 32; int locs_size = 32;
...@@ -2204,10 +2204,6 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2204,10 +2204,6 @@ class StubGenerator: public StubCodeGenerator {
// differently than the real call_VM // differently than the real call_VM
Register java_thread = rbx; Register java_thread = rbx;
__ get_thread(java_thread); __ get_thread(java_thread);
if (restore_saved_exception_pc) {
__ movptr(rax, Address(java_thread, in_bytes(JavaThread::saved_exception_pc_offset())));
__ push(rax);
}
__ enter(); // required for proper stackwalking of RuntimeStub frame __ enter(); // required for proper stackwalking of RuntimeStub frame
...@@ -2323,7 +2319,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2323,7 +2319,7 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_throw_WrongMethodTypeException_entry = StubRoutines::_throw_WrongMethodTypeException_entry =
generate_throw_exception("WrongMethodTypeException throw_exception", generate_throw_exception("WrongMethodTypeException throw_exception",
CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException), CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException),
false, rax, rcx); rax, rcx);
} }
...@@ -2332,12 +2328,10 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2332,12 +2328,10 @@ class StubGenerator: public StubCodeGenerator {
// These entry points require SharedInfo::stack0 to be set up in non-core builds // These entry points require SharedInfo::stack0 to be set up in non-core builds
// and need to be relocatable, so they each fabricate a RuntimeStub internally. // and need to be relocatable, so they each fabricate a RuntimeStub internally.
StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError), false); StubRoutines::_throw_AbstractMethodError_entry = generate_throw_exception("AbstractMethodError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError));
StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError), false); StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError));
StubRoutines::_throw_ArithmeticException_entry = generate_throw_exception("ArithmeticException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_ArithmeticException), true); StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call));
StubRoutines::_throw_NullPointerException_entry = generate_throw_exception("NullPointerException throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException), true); StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError));
StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
StubRoutines::_throw_StackOverflowError_entry = generate_throw_exception("StackOverflowError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
//------------------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------------------
// entry points that are platform specific // entry points that are platform specific
......
...@@ -935,6 +935,8 @@ class StubGenerator: public StubCodeGenerator { ...@@ -935,6 +935,8 @@ class StubGenerator: public StubCodeGenerator {
__ pusha(); // push registers __ pusha(); // push registers
Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord); Address next_pc(rsp, RegisterImpl::number_of_registers * BytesPerWord);
// FIXME: this probably needs alignment logic
__ subptr(rsp, frame::arg_reg_save_area_bytes); __ subptr(rsp, frame::arg_reg_save_area_bytes);
BLOCK_COMMENT("call handle_unsafe_access"); BLOCK_COMMENT("call handle_unsafe_access");
__ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access))); __ call(RuntimeAddress(CAST_FROM_FN_PTR(address, handle_unsafe_access)));
...@@ -2934,7 +2936,6 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2934,7 +2936,6 @@ class StubGenerator: public StubCodeGenerator {
// caller saved registers were assumed volatile in the compiler. // caller saved registers were assumed volatile in the compiler.
address generate_throw_exception(const char* name, address generate_throw_exception(const char* name,
address runtime_entry, address runtime_entry,
bool restore_saved_exception_pc,
Register arg1 = noreg, Register arg1 = noreg,
Register arg2 = noreg) { Register arg2 = noreg) {
// Information about frame layout at time of blocking runtime call. // Information about frame layout at time of blocking runtime call.
...@@ -2962,12 +2963,6 @@ class StubGenerator: public StubCodeGenerator { ...@@ -2962,12 +2963,6 @@ class StubGenerator: public StubCodeGenerator {
// which has the ability to fetch the return PC out of // which has the ability to fetch the return PC out of
// thread-local storage and also sets up last_Java_sp slightly // thread-local storage and also sets up last_Java_sp slightly
// differently than the real call_VM // differently than the real call_VM
if (restore_saved_exception_pc) {
__ movptr(rax,
Address(r15_thread,
in_bytes(JavaThread::saved_exception_pc_offset())));
__ push(rax);
}
__ enter(); // required for proper stackwalking of RuntimeStub frame __ enter(); // required for proper stackwalking of RuntimeStub frame
...@@ -3068,7 +3063,7 @@ class StubGenerator: public StubCodeGenerator { ...@@ -3068,7 +3063,7 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_throw_WrongMethodTypeException_entry = StubRoutines::_throw_WrongMethodTypeException_entry =
generate_throw_exception("WrongMethodTypeException throw_exception", generate_throw_exception("WrongMethodTypeException throw_exception",
CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException), CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException),
false, rax, rcx); rax, rcx);
} }
void generate_all() { void generate_all() {
...@@ -3081,43 +3076,25 @@ class StubGenerator: public StubCodeGenerator { ...@@ -3081,43 +3076,25 @@ class StubGenerator: public StubCodeGenerator {
generate_throw_exception("AbstractMethodError throw_exception", generate_throw_exception("AbstractMethodError throw_exception",
CAST_FROM_FN_PTR(address, CAST_FROM_FN_PTR(address,
SharedRuntime:: SharedRuntime::
throw_AbstractMethodError), throw_AbstractMethodError));
false);
StubRoutines::_throw_IncompatibleClassChangeError_entry = StubRoutines::_throw_IncompatibleClassChangeError_entry =
generate_throw_exception("IncompatibleClassChangeError throw_exception", generate_throw_exception("IncompatibleClassChangeError throw_exception",
CAST_FROM_FN_PTR(address, CAST_FROM_FN_PTR(address,
SharedRuntime:: SharedRuntime::
throw_IncompatibleClassChangeError), throw_IncompatibleClassChangeError));
false);
StubRoutines::_throw_ArithmeticException_entry =
generate_throw_exception("ArithmeticException throw_exception",
CAST_FROM_FN_PTR(address,
SharedRuntime::
throw_ArithmeticException),
true);
StubRoutines::_throw_NullPointerException_entry =
generate_throw_exception("NullPointerException throw_exception",
CAST_FROM_FN_PTR(address,
SharedRuntime::
throw_NullPointerException),
true);
StubRoutines::_throw_NullPointerException_at_call_entry = StubRoutines::_throw_NullPointerException_at_call_entry =
generate_throw_exception("NullPointerException at call throw_exception", generate_throw_exception("NullPointerException at call throw_exception",
CAST_FROM_FN_PTR(address, CAST_FROM_FN_PTR(address,
SharedRuntime:: SharedRuntime::
throw_NullPointerException_at_call), throw_NullPointerException_at_call));
false);
StubRoutines::_throw_StackOverflowError_entry = StubRoutines::_throw_StackOverflowError_entry =
generate_throw_exception("StackOverflowError throw_exception", generate_throw_exception("StackOverflowError throw_exception",
CAST_FROM_FN_PTR(address, CAST_FROM_FN_PTR(address,
SharedRuntime:: SharedRuntime::
throw_StackOverflowError), throw_StackOverflowError));
false);
// entry points that are platform specific // entry points that are platform specific
StubRoutines::x86::_f2i_fixup = generate_f2i_fixup(); StubRoutines::x86::_f2i_fixup = generate_f2i_fixup();
......
...@@ -215,12 +215,6 @@ class StubGenerator: public StubCodeGenerator { ...@@ -215,12 +215,6 @@ class StubGenerator: public StubCodeGenerator {
StubRoutines::_throw_AbstractMethodError_entry = StubRoutines::_throw_AbstractMethodError_entry =
ShouldNotCallThisStub(); ShouldNotCallThisStub();
StubRoutines::_throw_ArithmeticException_entry =
ShouldNotCallThisStub();
StubRoutines::_throw_NullPointerException_entry =
ShouldNotCallThisStub();
StubRoutines::_throw_NullPointerException_at_call_entry = StubRoutines::_throw_NullPointerException_at_call_entry =
ShouldNotCallThisStub(); ShouldNotCallThisStub();
......
...@@ -51,8 +51,6 @@ address StubRoutines::_catch_exception_entry = NULL; ...@@ -51,8 +51,6 @@ address StubRoutines::_catch_exception_entry = NULL;
address StubRoutines::_forward_exception_entry = NULL; address StubRoutines::_forward_exception_entry = NULL;
address StubRoutines::_throw_AbstractMethodError_entry = NULL; address StubRoutines::_throw_AbstractMethodError_entry = NULL;
address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL; address StubRoutines::_throw_IncompatibleClassChangeError_entry = NULL;
address StubRoutines::_throw_ArithmeticException_entry = NULL;
address StubRoutines::_throw_NullPointerException_entry = NULL;
address StubRoutines::_throw_NullPointerException_at_call_entry = NULL; address StubRoutines::_throw_NullPointerException_at_call_entry = NULL;
address StubRoutines::_throw_StackOverflowError_entry = NULL; address StubRoutines::_throw_StackOverflowError_entry = NULL;
address StubRoutines::_throw_WrongMethodTypeException_entry = NULL; address StubRoutines::_throw_WrongMethodTypeException_entry = NULL;
......
...@@ -128,8 +128,6 @@ class StubRoutines: AllStatic { ...@@ -128,8 +128,6 @@ class StubRoutines: AllStatic {
static address _catch_exception_entry; static address _catch_exception_entry;
static address _throw_AbstractMethodError_entry; static address _throw_AbstractMethodError_entry;
static address _throw_IncompatibleClassChangeError_entry; static address _throw_IncompatibleClassChangeError_entry;
static address _throw_ArithmeticException_entry;
static address _throw_NullPointerException_entry;
static address _throw_NullPointerException_at_call_entry; static address _throw_NullPointerException_at_call_entry;
static address _throw_StackOverflowError_entry; static address _throw_StackOverflowError_entry;
static address _throw_WrongMethodTypeException_entry; static address _throw_WrongMethodTypeException_entry;
...@@ -254,8 +252,6 @@ class StubRoutines: AllStatic { ...@@ -254,8 +252,6 @@ class StubRoutines: AllStatic {
// Implicit exceptions // Implicit exceptions
static address throw_AbstractMethodError_entry() { return _throw_AbstractMethodError_entry; } static address throw_AbstractMethodError_entry() { return _throw_AbstractMethodError_entry; }
static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; } static address throw_IncompatibleClassChangeError_entry(){ return _throw_IncompatibleClassChangeError_entry; }
static address throw_ArithmeticException_entry() { return _throw_ArithmeticException_entry; }
static address throw_NullPointerException_entry() { return _throw_NullPointerException_entry; }
static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; } static address throw_NullPointerException_at_call_entry(){ return _throw_NullPointerException_at_call_entry; }
static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; } static address throw_StackOverflowError_entry() { return _throw_StackOverflowError_entry; }
static address throw_WrongMethodTypeException_entry() { return _throw_WrongMethodTypeException_entry; } static address throw_WrongMethodTypeException_entry() { return _throw_WrongMethodTypeException_entry; }
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/**
* @test
* @bug 7088020
* @summary SEGV in JNIHandleBlock::release_block
*
* @run main Test7088020
*/
import java.lang.invoke.*;
public class Test7088020 {
public static boolean test() {
return false;
}
public static void main(String... args) throws Throwable {
MethodHandle test = MethodHandles.lookup().findStatic(Test7088020.class, "test", MethodType.methodType(Boolean.TYPE));
// Exercise WMT with different argument alignments
int thrown = 0;
try {
test.invokeExact(0);
} catch (WrongMethodTypeException wmt) {
thrown++;
if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
}
try {
test.invokeExact(0, 1);
} catch (WrongMethodTypeException wmt) {
thrown++;
if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
}
try {
test.invokeExact(0, 1, 2);
} catch (WrongMethodTypeException wmt) {
thrown++;
if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
}
try {
test.invokeExact(0, 1, 2, 3);
} catch (WrongMethodTypeException wmt) {
thrown++;
if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
}
try {
thrown++;
test.invokeExact(0, 1, 2, 3, 4);
} catch (WrongMethodTypeException wmt) {
if (wmt.getStackTrace().length < 1) throw new InternalError("missing stack frames");
}
if (thrown != 5) {
throw new InternalError("not enough throws");
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册