8213834: JVMTI ResourceExhausted should not be posted in CompilerThread
Reviewed-by: dholmes, dcubed, jcbeyler, sspitsyn
--- a/src/hotspot/share/prims/jvmtiExport.cpp Mon Nov 26 20:50:21 2018 -0800
+++ b/src/hotspot/share/prims/jvmtiExport.cpp Tue Nov 27 07:54:06 2018 +0100
@@ -1483,6 +1483,18 @@
}
void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const char* description) {
+
+ JavaThread *thread = JavaThread::current();
+
+ // JDK-8213834: handlers of ResourceExhausted may attempt some analysis
+ // which often requires running java.
+ // This will cause problems on threads not able to run java, e.g. compiler
+ // threads. To forestall these problems, we therefore suppress sending this
+ // event from threads which are not able to run java.
+ if (!thread->can_call_java()) {
+ return;
+ }
+
EVT_TRIG_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Trg resource exhausted event triggered" ));
JvmtiEnvIterator it;
@@ -1490,7 +1502,6 @@
if (env->is_enabled(JVMTI_EVENT_RESOURCE_EXHAUSTED)) {
EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Evt resource exhausted event sent" ));
- JavaThread *thread = JavaThread::current();
JvmtiThreadEventMark jem(thread);
JvmtiJavaThreadEventTransition jet(thread);
jvmtiEventResourceExhausted callback = env->callbacks()->ResourceExhausted;