Hi Thomas,
Thank you for taking care about this issue! We recently also saw a couple of problems related to the compiler thread not being hidden. I have several comments to the fix. It would be really nice if there is any chance to have a unit test for this. But I understand that it is not easy to minimize what you have in your agent. http://cr.openjdk.java.net/~stuefe/webrevs/8213834-jvmti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.00/webrev/src/hotspot/share/prims/jvmtiExport.cpp.udiff.html void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const char* description) { + + // Handlers may call back into the JVM as a reaction to this event, e.g. to print out + // a class histogram. Most of those actions require the ability to run java though. So + // lets not post this event in cases where we cannot run java (e.g. when a CompilerThread + // triggers a Metaspace OOM). + Thread* thread = Thread::current_or_null(); + if (thread == NULL || !thread->can_call_java()) { + return; + } + 1. Did you check that your fix does also work with the Graal enabled? The CompilerThread::can_call_java() should return true for JVMCI is used: bool CompilerThread::can_call_java() const { return _compiler != NULL && _compiler->is_jvmci(); } 2. It is better to use the is_hidden_from_external_view() instead of !can_call_java() 3. The 'thread' is already defined in post_resource_exhausted: JavaThread *thread = JavaThread::current(); But it is in a deeper scope. void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const char* description) { EVT_TRIG_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Trg resource exhausted event triggered" )); JvmtiEnvIterator it; for (JvmtiEnv* env = it.first(); env != NULL; env = it.next(env)) { if (env->is_enabled(JVMTI_EVENT_RESOURCE_EXHAUSTED)) { EVT_TRACE(JVMTI_EVENT_RESOURCE_EXHAUSTED, ("Evt resource exhausted event sent" )); JavaThread *thread = JavaThread::current(); I'd suggest to move it up as it is a better place for it anyway. Also, you do not need the extra check: if (thread == NULL || ! Thanks, Serguei On 11/14/18 07:06, Daniel D. Daugherty wrote: Adding serviceability-dev@... |
- Re: RFR(xs): 8213834: JVMTI ResourceExhausted s... Daniel D. Daugherty
- Re: RFR(xs): 8213834: JVMTI ResourceExhaus... serguei.spit...@oracle.com
- Re: RFR(xs): 8213834: JVMTI ResourceEx... serguei.spit...@oracle.com
- Re: RFR(xs): 8213834: JVMTI ResourceEx... David Holmes
- Re: RFR(xs): 8213834: JVMTI Resour... serguei.spit...@oracle.com
- Re: RFR(xs): 8213834: JVMTI ResourceExhaus... Daniel D. Daugherty
- Re: RFR(xs): 8213834: JVMTI ResourceEx... Thomas Stüfe
- Re: RFR(xs): 8213834: JVMTI Resour... Daniel D. Daugherty
- Re: RFR(xs): 8213834: JVMTI Re... David Holmes
- Re: RFR(xs): 8213834: JVM... Daniel D. Daugherty
- Re: RFR(xs): 8213834:... David Holmes
- Re: RFR(xs): 8213... Thomas Stüfe