mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
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
5 changed files with 70 additions and 32 deletions
|
@ -488,6 +488,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
if (last_sp != saved_sp && last_sp != NULL)
|
if (last_sp != saved_sp && last_sp != NULL)
|
||||||
tty->print_cr("*** last_sp=" INTPTR_FORMAT, p2i(last_sp));
|
tty->print_cr("*** last_sp=" INTPTR_FORMAT, p2i(last_sp));
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
|
ResourceMark rm;
|
||||||
tty->print(" reg dump: ");
|
tty->print(" reg dump: ");
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < trace_mh_nregs; i++) {
|
for (i = 0; i < trace_mh_nregs; i++) {
|
||||||
|
@ -497,9 +498,8 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
tty->print(" %s: " INTPTR_FORMAT, reg_name, p2i((void *)saved_regs[i]));
|
tty->print(" %s: " INTPTR_FORMAT, reg_name, p2i((void *)saved_regs[i]));
|
||||||
}
|
}
|
||||||
tty->cr();
|
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
|
// Note: code is robust but the dumped informationm may not be
|
||||||
|
@ -509,7 +509,6 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
// will be identified by *Rsender_sp anyway in the dump.
|
// will be identified by *Rsender_sp anyway in the dump.
|
||||||
JavaThread* p = JavaThread::active();
|
JavaThread* p = JavaThread::active();
|
||||||
|
|
||||||
ResourceMark rm;
|
|
||||||
PRESERVE_EXCEPTION_MARK;
|
PRESERVE_EXCEPTION_MARK;
|
||||||
FrameValues values;
|
FrameValues values;
|
||||||
|
|
||||||
|
@ -529,15 +528,16 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
tty->print_cr(" stack layout:");
|
tty->print_cr(" stack layout:");
|
||||||
values.print(p);
|
values.print(p);
|
||||||
}
|
}
|
||||||
if (Verbose) {
|
|
||||||
if (has_mh && oopDesc::is_oop(mh)) {
|
if (has_mh && oopDesc::is_oop(mh)) {
|
||||||
mh->print();
|
mh->print();
|
||||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
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();
|
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
|
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
|
||||||
|
|
|
@ -483,6 +483,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
adaptername, mh_reg_name, p2i(mh), p2i(entry_sp));
|
adaptername, mh_reg_name, p2i(mh), p2i(entry_sp));
|
||||||
|
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
|
ResourceMark rm;
|
||||||
tty->print_cr("Registers:");
|
tty->print_cr("Registers:");
|
||||||
const int abi_offset = frame::abi_reg_args_size / 8;
|
const int abi_offset = frame::abi_reg_args_size / 8;
|
||||||
for (int i = R3->encoding(); i <= R12->encoding(); i++) {
|
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();
|
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 by safer and unexpensive here
|
||||||
FrameValues values;
|
FrameValues values;
|
||||||
|
|
||||||
|
@ -538,11 +538,12 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
if (has_mh && oopDesc::is_oop(mh)) {
|
if (has_mh && oopDesc::is_oop(mh)) {
|
||||||
mh->print();
|
mh->print();
|
||||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
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();
|
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
|
void MethodHandles::trace_method_handle(MacroAssembler* _masm, const char* adaptername) {
|
||||||
|
|
|
@ -502,6 +502,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
p2i(mh), p2i(entry_sp));
|
p2i(mh), p2i(entry_sp));
|
||||||
|
|
||||||
if (Verbose) {
|
if (Verbose) {
|
||||||
|
ResourceMark rm;
|
||||||
tty->print_cr("Registers:");
|
tty->print_cr("Registers:");
|
||||||
const int saved_regs_count = RegisterImpl::number_of_registers;
|
const int saved_regs_count = RegisterImpl::number_of_registers;
|
||||||
for (int i = 0; i < saved_regs_count; i++) {
|
for (int i = 0; i < saved_regs_count; i++) {
|
||||||
|
@ -531,8 +532,7 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
|
|
||||||
JavaThread* p = JavaThread::active();
|
JavaThread* p = JavaThread::active();
|
||||||
|
|
||||||
ResourceMark rm;
|
PRESERVE_EXCEPTION_MARK; // may not be needed but safer and inexpensive here
|
||||||
PRESERVE_EXCEPTION_MARK; // may not be needed by safer and unexpensive here
|
|
||||||
FrameValues values;
|
FrameValues values;
|
||||||
|
|
||||||
// Note: We want to allow trace_method_handle from any call site.
|
// Note: We want to allow trace_method_handle from any call site.
|
||||||
|
@ -581,11 +581,12 @@ void trace_method_handle_stub(const char* adaptername,
|
||||||
if (has_mh && oopDesc::is_oop(mh)) {
|
if (has_mh && oopDesc::is_oop(mh)) {
|
||||||
mh->print();
|
mh->print();
|
||||||
if (java_lang_invoke_MethodHandle::is_instance(mh)) {
|
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();
|
java_lang_invoke_MethodHandle::form(mh)->print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The stub wraps the arguments in a struct on the stack to avoid
|
// The stub wraps the arguments in a struct on the stack to avoid
|
||||||
|
|
|
@ -774,6 +774,7 @@ void Klass::print_on(outputStream* st) const {
|
||||||
|
|
||||||
#define BULLET " - "
|
#define BULLET " - "
|
||||||
|
|
||||||
|
// Caller needs ResourceMark
|
||||||
void Klass::oop_print_on(oop obj, outputStream* st) {
|
void Klass::oop_print_on(oop obj, outputStream* st) {
|
||||||
// print title
|
// print title
|
||||||
st->print_cr("%s ", internal_name());
|
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…
Add table
Add a link
Reference in a new issue