<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">On 11/14/18 11:20,
<a class="moz-txt-link-abbreviated" href="mailto:***@oracle.com">***@oracle.com</a> wrote:<br>
</div>
<blockquote type="cite"
cite="mid:bb5f88ff-b9ca-2f34-3adb-***@oracle.com">
<div class="moz-cite-prefix">Hi Thomas,<br>
<br>
Thank you for taking care about this issue!<br>
We recently also saw a couple of problems related to the
compiler thread not being hidden.<br>
<br>
I have several comments to the fix.<br>
<br>
It would be really nice if there is any chance to have a unit
test for this.<br>
But I understand that it is not easy to minimize what you have
in your agent.<br>
<br>
<a class="moz-txt-link-freetext"
href="http://cr.openjdk.java.net/%7Estuefe/webrevs/8213834-jvmti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.00/webrev/src/hotspot/share/prims/jvmtiExport.cpp.udiff.html"
moz-do-not-send="true">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</a><br> <pre> void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const char* description) { <span class="new">+</span> <span class="new">+ // Handlers may call back into the JVM as a reaction to this event, e.g. to print out</span> <span class="new">+ // a class histogram. Most of those actions require the ability to run java though. So</span> <span class="new">+ // lets not post this event in cases where we cannot run java (e.g. when a CompilerThread</span> <span class="new">+ // triggers a Metaspace OOM).</span> <span class="new">+ Thread* thread = Thread::current_or_null();</span> <span class="new">+ if (thread == NULL || !thread->can_call_java()) {</span>
<span class="new">+ return;</span>
<span class="new">+ }</span>
<span class="new">+
</span>
<span class="new"><span class="new">1. Did you check that your fix does also work with the Graal enabled?</span>
The CompilerThread:</span><span class="new"><span class="new">:can_call_java() should return true for JVMCI is used:
</span>
bool CompilerThread::can_call_java() const {
return _compiler != NULL && _compiler->is_jvmci();
}</span></pre>
</div>
</blockquote>
<br>
We may want to use a pattern below:<br>
<br>
bool
JvmtiSampledObjectAllocEventCollector::object_alloc_is_safe_to_sample()
{<br>
Thread* thread = Thread::current();<br>
// Really only sample allocations if this is a JavaThread and not
the compiler<br>
// thread.<br>
if (!thread->is_Java_thread() ||
thread->is_Compiler_thread()) {<br>
return false;<br>
}<br>
<br>
<span class="new"></span><span class="new">Thanks,<br>
Serguei<br>
<br>
</span><span class="new"></span>
<blockquote type="cite"
cite="mid:bb5f88ff-b9ca-2f34-3adb-***@oracle.com">
<div class="moz-cite-prefix">
<pre><span class="new">2. It is better to use the is_hidden_from_external_view() instead of !</span><span class="new"><span class="new">can_call_java()
</span></span>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:
<span class="new"> if (thread == NULL || !</span><span class="new"></span></pre>
<br>
Thanks,<br>
Serguei<br>
<br>
<br>
On 11/14/18 07:06, Daniel D. Daugherty wrote:<br>
</div>
<blockquote type="cite"
cite="mid:b0508ce8-e587-0949-f40f-***@oracle.com">Adding
serviceability-***@... <br>
<br>
Since the proposed solution to the bug is to not post an event,
I think <br>
the Serviceability Team (which owns JVM/TI) needs to be involved
directly <br>
in the review. <br>
<br>
Dan <br>
<br>
<br>
On 11/14/18 9:28 AM, Thomas Stüfe wrote: <br>
<blockquote type="cite">Dear all, <br>
<br>
may I please have reviews on this small patch. Note that this
is <br>
borderline serviceability. I try to avoid crossposting, but if
you <br>
think this should be looked at by serviceability feel free to
forward <br>
it there. <br>
<br>
Issue: <a class="moz-txt-link-freetext"
href="https://bugs.openjdk.java.net/browse/JDK-8213834"
moz-do-not-send="true">https://bugs.openjdk.java.net/browse/JDK-8213834</a>
<br>
<br>
CR:
<a class="moz-txt-link-freetext"
href="http://cr.openjdk.java.net/%7Estuefe/webrevs/8213834-jvmti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.00/webrev/"
moz-do-not-send="true">http://cr.openjdk.java.net/~stuefe/webrevs/8213834-jvmti-reourceexhausted-shall-not-be-posted-from-compiler-thread/webrev.00/webrev/</a><br>
<br>
Short description: we may post ResourceExhausted from Compiler
<br>
threads. Handlers of this event may call back into the JVM,
which may <br>
cause problems since we run in the compiler thread. The
proposed <br>
solution is not to post the event in that case. <br>
<br>
See previous discussion here: <br>
<a class="moz-txt-link-freetext"
href="http://mail.openjdk.java.net/pipermail/serviceability-dev/2018-November/025898.html"
moz-do-not-send="true">http://mail.openjdk.java.net/pipermail/serviceability-dev/2018-November/025898.html</a>
<br>
<br>
Thanks, Thomas <br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>