8213834: JVMTI ResourceExhausted should not be posted in CompilerThread

Reviewed-by: dholmes, dcubed, jcbeyler, sspitsyn
This commit is contained in:
Thomas Stuefe 2018-11-27 07:54:06 +01:00
parent 23ecdbbc1d
commit abf1e47f29

@ -1483,6 +1483,18 @@ void JvmtiExport::post_object_free(JvmtiEnv* env, jlong tag) {
}
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 @@ void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const c
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;