JDK-8220718 : Missing ResourceMark in nmethod::metadata_do
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 8,11
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2019-03-15
  • Updated: 2020-08-27
  • Resolved: 2019-03-19
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 Other
11.0.10-oracleFixed openjdk8u222Fixed
Related Reports
Relates :  
Relates :  
Description
Reported here:
 https://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2019-March/033111.html

It seems that CompiledIC is a ResourceObj, that is allocated in CompiledIC_at() call, but never reclaimed locally because of the missing ResourceMark. I think there is some upper-level ResourceMark that keeps build from asserting that allocation is done without the ResourceMark, but it probably too far up to be useful for reclaiming this temporary allocation.

This is fixed starting JDK 12 with JDK-8208677:
  http://hg.openjdk.java.net/jdk/jdk/rev/aa3bfacc912c#l4.7

...but we need to do the same in 11u and 8u.

aotCompiledMethod.cpp has the ResourceMark in similar place, brought in by JDK-8206394:
 http://hg.openjdk.java.net/jdk/jdk/file/aa3bfacc912c/src/hotspot/share/aot/aotCompiledMethod.cpp#l274
Comments
Fix Request (8u) This patch avoids the native OOM in C2 in some corner cases. Patch applies to 8u with reshuffling, and passes hotspot jtreg tests on Linux x86_64.
20-03-2019

Fix Request (11u) This patch avoids the native OOM in C2 in some corner cases. Patch is present in 12u+, in much larger changeset. This small change runs tier {1,2,3} fine. RFR: https://mail.openjdk.java.net/pipermail/jdk-updates-dev/2019-March/000806.html
19-03-2019

Suggested fix: diff -r 3086207c8650 src/hotspot/share/code/nmethod.cpp --- a/src/hotspot/share/code/nmethod.cpp Tue Mar 05 08:24:58 2019 -0500 +++ b/src/hotspot/share/code/nmethod.cpp Fri Mar 15 12:09:10 2019 +0100 @@ -1538,10 +1538,11 @@ Metadata* md = r->metadata_value(); if (md != _method) f(md); } } else if (iter.type() == relocInfo::virtual_call_type) { // Check compiledIC holders associated with this nmethod + ResourceMark rm; CompiledIC *ic = CompiledIC_at(&iter); if (ic->is_icholder_call()) { CompiledICHolder* cichk = ic->cached_icholder(); f(cichk->holder_metadata()); f(cichk->holder_klass()); ...passes tier{1,2,3} in jdk-updates/jdk11u-dev with Linux x86_64 fastdebug.
15-03-2019