8244946: fatal error: memory leak: allocating without ResourceMark with -XX:+Verbose -Xlog:methodhandles
Fix crash due to a missing ResourceMark when logging methodhandles with Verbose. Reviewed-by: dcubed, dholmes, coleenp
This commit is contained in:
parent
de4b15e52e
commit
9b94b9d1a1
@ -488,6 +488,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
if (last_sp != saved_sp && last_sp != NULL)
|
||||
tty->print_cr("*** last_sp=" INTPTR_FORMAT, p2i(last_sp));
|
||||
if (Verbose) {
|
||||
ResourceMark rm;
|
||||
tty->print(" reg dump: ");
|
||||
int i;
|
||||
for (i = 0; i < trace_mh_nregs; i++) {
|
||||
@ -497,44 +498,43 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
tty->print(" %s: " INTPTR_FORMAT, reg_name, p2i((void *)saved_regs[i]));
|
||||
}
|
||||
tty->cr();
|
||||
}
|
||||
|
||||
if (Verbose) {
|
||||
// dump last frame (from JavaThread::print_frame_layout)
|
||||
{
|
||||
// dump last frame (from JavaThread::print_frame_layout)
|
||||
|
||||
// Note: code is robust but the dumped informationm may not be
|
||||
// 100% correct, particularly with respect to the dumped
|
||||
// "unextended_sp". Getting it right for all trace_method_handle
|
||||
// call paths is not worth the complexity/risk. The correct slot
|
||||
// will be identified by *Rsender_sp anyway in the dump.
|
||||
JavaThread* p = JavaThread::active();
|
||||
// Note: code is robust but the dumped informationm may not be
|
||||
// 100% correct, particularly with respect to the dumped
|
||||
// "unextended_sp". Getting it right for all trace_method_handle
|
||||
// call paths is not worth the complexity/risk. The correct slot
|
||||
// will be identified by *Rsender_sp anyway in the dump.
|
||||
JavaThread* p = JavaThread::active();
|
||||
|
||||
ResourceMark rm;
|
||||
PRESERVE_EXCEPTION_MARK;
|
||||
FrameValues values;
|
||||
PRESERVE_EXCEPTION_MARK;
|
||||
FrameValues values;
|
||||
|
||||
intptr_t* dump_fp = (intptr_t *) saved_bp;
|
||||
address dump_pc = (address) saved_regs[trace_mh_nregs-2]; // LR (with LR,PC last in saved_regs)
|
||||
frame dump_frame((intptr_t *)entry_sp, dump_fp, dump_pc);
|
||||
intptr_t* dump_fp = (intptr_t *) saved_bp;
|
||||
address dump_pc = (address) saved_regs[trace_mh_nregs-2]; // LR (with LR,PC last in saved_regs)
|
||||
frame dump_frame((intptr_t *)entry_sp, dump_fp, dump_pc);
|
||||
|
||||
dump_frame.describe(values, 1);
|
||||
// mark Rsender_sp if seems valid
|
||||
if (has_mh) {
|
||||
if ((saved_sp >= entry_sp - UNREASONABLE_STACK_MOVE) && (saved_sp < dump_fp)) {
|
||||
values.describe(-1, saved_sp, "*Rsender_sp");
|
||||
dump_frame.describe(values, 1);
|
||||
// mark Rsender_sp if seems valid
|
||||
if (has_mh) {
|
||||
if ((saved_sp >= entry_sp - UNREASONABLE_STACK_MOVE) && (saved_sp < dump_fp)) {
|
||||
values.describe(-1, saved_sp, "*Rsender_sp");
|
||||
}
|
||||
}
|
||||
|
||||
// Note: the unextended_sp may not be correct
|
||||
tty->print_cr(" stack layout:");
|
||||
values.print(p);
|
||||
}
|
||||
|
||||
// Note: the unextended_sp may not be correct
|
||||
tty->print_cr(" stack layout:");
|
||||
values.print(p);
|
||||
}
|
||||
if (Verbose) {
|
||||
if (has_mh && oopDesc::is_oop(mh)) {
|
||||
mh->print();
|
||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
||||
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0)
|
||||
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0) {
|
||||
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -483,6 +483,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
adaptername, mh_reg_name, p2i(mh), p2i(entry_sp));
|
||||
|
||||
if (Verbose) {
|
||||
ResourceMark rm;
|
||||
tty->print_cr("Registers:");
|
||||
const int abi_offset = frame::abi_reg_args_size / 8;
|
||||
for (int i = R3->encoding(); i <= R12->encoding(); i++) {
|
||||
@ -503,7 +504,6 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
|
||||
JavaThread* p = JavaThread::active();
|
||||
|
||||
ResourceMark rm;
|
||||
PRESERVE_EXCEPTION_MARK; // may not be needed by safer and unexpensive here
|
||||
FrameValues values;
|
||||
|
||||
@ -538,8 +538,9 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
if (has_mh && oopDesc::is_oop(mh)) {
|
||||
mh->print();
|
||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
||||
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0)
|
||||
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0) {
|
||||
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -502,6 +502,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
p2i(mh), p2i(entry_sp));
|
||||
|
||||
if (Verbose) {
|
||||
ResourceMark rm;
|
||||
tty->print_cr("Registers:");
|
||||
const int saved_regs_count = RegisterImpl::number_of_registers;
|
||||
for (int i = 0; i < saved_regs_count; i++) {
|
||||
@ -527,12 +528,11 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
tty->cr();
|
||||
|
||||
{
|
||||
// dumping last frame with frame::describe
|
||||
// dumping last frame with frame::describe
|
||||
|
||||
JavaThread* p = JavaThread::active();
|
||||
|
||||
ResourceMark rm;
|
||||
PRESERVE_EXCEPTION_MARK; // may not be needed by safer and unexpensive here
|
||||
PRESERVE_EXCEPTION_MARK; // may not be needed but safer and inexpensive here
|
||||
FrameValues values;
|
||||
|
||||
// Note: We want to allow trace_method_handle from any call site.
|
||||
@ -581,8 +581,9 @@ void trace_method_handle_stub(const char* adaptername,
|
||||
if (has_mh && oopDesc::is_oop(mh)) {
|
||||
mh->print();
|
||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
||||
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0)
|
||||
if (java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0) {
|
||||
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -774,6 +774,7 @@ void Klass::print_on(outputStream* st) const {
|
||||
|
||||
#define BULLET " - "
|
||||
|
||||
// Caller needs ResourceMark
|
||||
void Klass::oop_print_on(oop obj, outputStream* st) {
|
||||
// print title
|
||||
st->print_cr("%s ", internal_name());
|
||||
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 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 8244946
|
||||
* @summary Run simple test with -XX:+Verbose and -Xlog:methodhandles.
|
||||
*
|
||||
* @run main/othervm -XX:+Verbose -Xlog:methodhandles TestMethodHandlesVerbose
|
||||
*/
|
||||
|
||||
public class TestMethodHandlesVerbose {
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user