JDK-8213834 : JVMTI ResourceExhausted should not be posted in CompilerThread
  • Type: Bug
  • Component: hotspot
  • Sub-Component: jvmti
  • Affected Version: 12
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2018-11-14
  • Updated: 2023-11-30
  • Resolved: 2018-11-27
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 JDK 12
11.0.3Fixed 12 b22Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
A typical way jvmti agents handle ResourceExhausted is to access the JVM  to obtain more information. That usually means running Java. For example, the CloudFoundry jvmkill ([1]) agent will use FollowReferences() to traverse the heap and to generate a class histogram.

That means ResourceExhausted events should only posted in threads which are able to call into java without problems.

Background: I am looking at a problem described in more detail here: [2]

CloudFoundry uses a tiny jvmti agent, jvmkill, which subscribes to ResourceExhausted and as a reaction to that event prints a class histogram. It crashes while doing so:

#  guarantee(!thread->is_Compiler_thread()) failed: cannot make java calls from the compiler

The reason is that we encounter a MetaspaceOOM in the compiler. Compiler allocates Metaspace for MethodData and MethodCounter objects. It would never actually leak those OOMs to the user but handle them internally. But since ResourceExhausted is posted, the CF jvmkill agent then runs its handler in the CompilerThread and triggers above assertion.

The solution would be to either not post ResourceExhausted in CompilerThreads or, alternatively, to not post ResourceExhausted when the current thread cannot call java.

--

[1] https://github.com/cloudfoundry/jvmkill
[2] https://github.com/cloudfoundry/java-buildpack/issues/500

Comments
Fix Request Bug causes crashes in "jvmkill" jvmti agent on CloudFoundry. The fix prevents sending ResourceExhausted jvmti event from threads which are not able to run java, which includes the traditional compiler threads. Fix is minimal-invasive and risk is low: at the most, we risk unnecessarily suppressing an ResourceExhausted event but since other such events are extremely likely, and are extremely likely in normal java threads, the risk is very low. The patch applies cleanly to 11u.
27-11-2018

URL: http://hg.openjdk.java.net/jdk/jdk/rev/d9f6a700fec9 User: stuefe Date: 2018-11-27 06:55:14 +0000
27-11-2018

Discussion Thread: http://mail.openjdk.java.net/pipermail/hotspot-runtime-dev/2018-November/031107.html Webrev under discussion: http://cr.openjdk.java.net/~stuefe/webrevs/8213834-jvmti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.00/webrev/
21-11-2018

Moving from hotspot/svc -> hotspot/jvmti.
14-11-2018