[15] RFR(XS): 8244946: fatal error: memory leak: allocating without ResourceMark with -XX:+Verbose -Xlog:methodhandles
Daniel D. Daugherty
daniel.daugherty at oracle.com
Wed May 13 15:54:18 UTC 2020
On 5/13/20 11:10 AM, Christian Hagedorn wrote:
> Hi
>
> Please review the following patch:
> https://bugs.openjdk.java.net/browse/JDK-8244946
> http://cr.openjdk.java.net/~chagedorn/8244946/webrev.00/
src/hotspot/cpu/x86/methodHandles_x86.cpp
I was looking at your expanded scope and I happened to see:
L525: PRESERVE_EXCEPTION_MARK; // may not be needed by
safer and unexpensive here
Not your bug, but the comment has two typos:
s/by safer/but safer/
s/unexpensive/inexpensive/
So your expanded scope now extends the PRESERVE_EXCEPTION_MARK over
this block:
L571: if (has_mh && oopDesc::is_oop(mh)) {
L572: mh->print();
L573: if (java_lang_invoke_MethodHandle::is_instance(mh)) {
L574: if
(java_lang_invoke_MethodHandle::form_offset_in_bytes() != 0) {
L575: java_lang_invoke_MethodHandle::form(mh)->print();
L576: }
L577: }
L578: }
I don't see anything worrisome about extending the
PRESERVE_EXCEPTION_MARK, but I'm not really an invoke/MethodHandle
expert here. :-)
src/hotspot/share/oops/klass.cpp
No comments.
test/hotspot/jtreg/runtime/logging/TestMethodHandlesVerbose.java
Thanks for including a test.
Thumbs up.
Dan
>
> This simply fixes a missing ResourceMark required to call
> Klass::oop_print_on().
>
> The reason for the missing ResourceMark in oop_print_on() is stated in
> the RFR [1] for JDK-8222893 [2] which removed the ResourceMark due to
> a bug:
>
> "print functions with outputStream should not have a ResourceMark
> because you could call it with a LogStream or stream that was
> allocated outside the resource mark. The caller needs the ResourceMark."
>
> There are other places like Klass::print_on(outputStream*) where this
> is still the case. Should we file an RFE to clean these up?
>
> Thank you!
>
> Best regards,
> Christian
>
>
> [1]
> https://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2019-May/034095.html
> [2] https://bugs.openjdk.java.net/browse/JDK-8222893
More information about the hotspot-dev
mailing list