<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/16/18 10:41,
<a class="moz-txt-link-abbreviated" href="mailto:***@oracle.com">***@oracle.com</a> wrote:<br>
</div>
<blockquote type="cite"
cite="mid:6a5f2f33-6342-cae3-d47e-***@oracle.com">
<div class="moz-cite-prefix">Hi Ioi,<br>
<br>
Thank you for the clarifications!<br>
<br>
But then I have one more question to the fix in webrev.<br>
<br>
<a class="moz-txt-link-freetext"
href="http://cr.openjdk.java.net/%7Eccheung/8201375/webrev.00/src/hotspot/share/runtime/thread.cpp.udiff.html"
moz-do-not-send="true">http://cr.openjdk.java.net/%7Eccheung/8201375/webrev.00/src/hotspot/share/runtime/thread.cpp.udiff.html</a><br> <pre><b> // Create agents for -agentlib: -agentpath: and converted -Xrun</b> <b> // Invokes Agent_OnLoad</b> <b> // Called very early -- before JavaThreads exist</b> <b> void Threads::create_vm_init_agents() {</b> <b>+ if (DumpSharedSpaces && !AllowArchivingWithJavaAgent) {</b> <b>+ vm_exit_during_cds_dumping(</b> <b>+ "Must enable AllowArchivingWithJavaAgent in order to run Java agent during CDS dumping");</b> <b>+ }</b> <b> extern struct JavaVM_ main_vm;</b> <b> AgentLibrary* agent;</b> <b> </b> <b> JvmtiExport::enter_onload_phase();</b> <b> </b> <b> for (agent = Arguments::agents(); agent != NULL; agent = agent->next()) {</b> <b>+ // CDS dumping does not support native JVMTI agent</b> <b>+ if (DumpSharedSpaces && !agent->is_instrument_lib()) {</b> <b>+ vm_exit_during_cds_dumping("CDS dumping does not support native JVMTI agent, name", agent->name());</b> <b>+ }</b> <b>+ </b> <b> OnLoadEntry_t on_load_entry = lookup_agent_on_load(agent);</b> <b> </b> <b> if (on_load_entry != NULL) {</b> <b> // Invoke the Agent_OnLoad function</b> <b> jint err = (*on_load_entry)(&main_vm, agent->options(), NULL);</b></pre>
<br>
If !<b>agent->is_instrument_lib()</b> is passed then it will
be rejected with the message:<b><br>
"Must enable AllowArchivingWithJavaAgent in order to run
Java agent during CDS dumping"</b> <br>
which is incorrect.<br>
<br>
Probably, the fix needs to be something like this:<br> <pre><b> for (agent = Arguments::agents(); agent != NULL; agent = agent->next()) {</b> <b>+ // CDS dumping does not support native JVMTI agent</b> <b>+ if (DumpSharedSpaces && !agent->is_instrument_lib()) {</b> <b>+ vm_exit_during_cds_dumping("CDS dumping does not support native JVMTI agent, name", agent->name());</b> <b>+ }</b> <b>+ // CDS dumping does not support native JVMTI agent</b> <b>+ else if (DumpSharedSpaces && !agent->is_instrument_lib()) {</b> <b>+ vm_exit_during_cds_dumping("CDS dumping does not support native JVMTI agent, name", agent->name());</b>
<b>+ }</b>
</pre>
</div>
</blockquote>
Sorry, somehow I've copy-pasted wrong fragment.<br>
It has to be:<br> <pre><b> for (agent = Arguments::agents(); agent != NULL; agent = agent->next()) {</b>
<b>+ // CDS dumping does not support native JVMTI agent</b>
<b>+ if (DumpSharedSpaces) {
+ if(!agent->is_instrument_lib()) {</b> <b>+ vm_exit_during_cds_dumping("CDS dumping does not support native JVMTI agent, name", agent->name());</b>
<b>+ }</b>
<b>+ else if (!AllowArchivingWithJavaAgent) {</b>
<b>+ vm_exit_during_cds_dumping(</b>
<b>+ "Must enable AllowArchivingWithJavaAgent in order to run Java agent during CDS dumping");</b>
<b>+ }
+ }
</b></pre>
And this fragment at the begin of the function needs to be removed:<br>
<pre><b>+ if (DumpSharedSpaces && !AllowArchivingWithJavaAgent) {</b>
<b>+ vm_exit_during_cds_dumping(</b>
<b>+ "Must enable AllowArchivingWithJavaAgent in order to run Java agent during CDS dumping");</b>
<b>+ }</b></pre>
<br>
Thanks,<br>
Serguei<br>
<br>
<blockquote type="cite"
cite="mid:6a5f2f33-6342-cae3-d47e-***@oracle.com">
<div class="moz-cite-prefix"> Thanks,<br>
Serguei<br>
<br>
<br>
<br>
<br>
<br>
On 11/16/18 10:18, Ioi Lam wrote:<br>
</div>
<blockquote type="cite"
cite="mid:25737bd7-9333-480b-8ee6-***@oracle.com"> <br>
<br>
On 11/16/18 9:45 AM, <a class="moz-txt-link-abbreviated"
href="mailto:***@oracle.com"
moz-do-not-send="true">***@oracle.com</a> wrote: <br>
<blockquote type="cite">Hi Calvin, <br>
<br>
On 11/16/18 09:26, Calvin Cheung wrote: <br>
<blockquote type="cite">Serguei, Dan, <br>
<br>
Thanks for taking a look. <br>
<br>
I think the option name is correct but the comment for
Threads::create_vm_init_agents() is incorrect as I believe
it will start both Java native agents. Otherwise, my new
tests won't work. <br>
</blockquote>
<br>
It works because there is the system JVMTI (native) agent
library libinstrument.so that is supporting java agents. <br>
It means that new option first impacts native agents and
transitively java agents as well via the libinstrument.so. <br>
<br>
Dan already asked the question about your original
reasoning/intention. <br>
If your intention is to control java agent only then the fix
is wrong as the real impact is much bigger. <br>
If you wanted to control all the agents then the new option
name is misleading. <br>
<br>
<br>
</blockquote>
The intention of this change is: <br>
<br>
Disallow all use of native and java agents by default. -- using
agents during dump time will cause undesirable side effects and
make the CDS archive unsuitable for production environments. <br>
<br>
However, for testing CDS itself, we want to use the Java agent
(to run arbitrary Java code during dump time, such as causing GC
at specific times). <br>
<br>
As a result, what we are doing is: <br>
<br>
+ Always disallow non-Java agents. <br>
+ Allow java agents only if AllowArchivingWithJavaAgent is
specified. <br>
<br>
I think we should clean up the bug title and description if
necessary. However, the behavior of this patch is what we want.
And I think the naming of the AllowArchivingWithJavaAgent option
is correct (as least in the sense of "anything not explicitly
allow are strictly forbidden" :-) <br>
<br>
Thanks <br>
- Ioi <br>
<br>
<br>
<blockquote type="cite">
<blockquote type="cite">Below is my understanding: <br>
<br>
In thread.cpp: <br>
<br>
3697 if (Arguments::init_agents_at_startup()) { <br>
3698 create_vm_init_agents(); <br>
3699 } <br>
<br>
init_agents_at_startup() checks if the _agentList is empty
in arguments.hpp: <br>
<br>
static bool init_agents_at_startup() { return
!_agentList.is_empty(); } <br>
<br>
In arguments.cpp, entries will be added to the _agentList
during the parsing of the -agentLib, -agentPath, and
-javaagent arguments. See lines around 2463-2502. <br>
For the -agentLib and -agentPath args, the _agentList will
be populated via the add_init_agent() function. For the
-javaagent, the _agentList will be populated via the
add_instrument_agent() function. <br>
<br>
So in create_vm_init_agents(), it will just loop through the
_agentList and starts all the agents. There's a check for
!agent->is_instrument_agent() at line 4092 which is for
not allowing any JVMTI (native) agent to be run during dump
time. <br>
<br>
One more reply to Serguei's comment below... <br>
</blockquote>
<br>
Okay, thank you for the update! <br>
<br>
Thanks, <br>
Serguei <br>
<br>
<blockquote type="cite"> <br>
thanks, <br>
Calvin <br>
<br>
On 11/16/18, 6:08 AM, Daniel D. Daugherty wrote: <br> <blockquote type="cite">> The flags -agentlib and
-agentpath are to run JVMTI (native) agents, <br>
> and Agent_OnLoad is an entrypoint in native agent
library. <br>
<br>
The '-agentlib' and '-agentpath' options are used to load
and execute <br>
a native library via the Agent_OnLoad() entry point.
However, the <br>
agent does not have to use JVM/TI (it could be pure JNI):
<br>
<br>
$ java -help <br>
<br>
-agentlib:<libname>[=<options>] <br>
load native agent library
<libname>, e.g. -agentlib:hprof <br>
see also, -agentlib:jdwp=help and
-agentlib:hprof=help <br>
-agentpath:<pathname>[=<options>] <br>
load native agent library by full
pathname <br>
<br>
The '-javaagent' option is used to load and execute a Java
agent: <br>
<br>
-javaagent:<jarpath>[=<options>] <br>
load Java programming language agent,
see java.lang.instrument <br>
<br>
so I agree that the option is misnamed (a bit), but the
reasons <br>
needed to be clarified. <br>
<br>
Dan <br>
<br>
<br>
On 11/16/18 1:39 AM, <a class="moz-txt-link-abbreviated"
href="mailto:***@oracle.com"
moz-do-not-send="true">***@oracle.com</a>
wrote: <br>
<blockquote type="cite">Hi Calvin, <br>
<br>
It seems the option name AllowArchivingWithJavaAgent is
not right. <br>
In fact, it is about JVMTI (native) agents: <br>
<br>
*// Create agents for -agentlib: -agentpath: and
converted -Xrun* <br>
*// Invokes Agent_OnLoad* <br>
*// Called very early -- before JavaThreads exist* <br>
*void Threads::create_vm_init_agents() {* <br>
*+ if (DumpSharedSpaces &&
!AllowArchivingWithJavaAgent) {* <br>
*+ vm_exit_during_cds_dumping(* <br>
*+ "Must enable AllowArchivingWithJavaAgent in order to
run Java agent during CDS dumping");* <br>
*+ }* <br>
*extern struct JavaVM_ main_vm;* <br>
*AgentLibrary* agent;* <br>
** <br>
*JvmtiExport::enter_onload_phase();* <br>
** <br>
*for (agent = Arguments::agents(); agent != NULL; agent
= agent->next()) {* <br>
*+ // CDS dumping does not support native JVMTI agent* <br>
*+ if (DumpSharedSpaces &&
!agent->is_instrument_lib()) {* <br>
*+ vm_exit_during_cds_dumping("CDS dumping does not
support native JVMTI agent, name", agent->name());* <br>
*+ }* <br>
*+ * <br>
*OnLoadEntry_t on_load_entry =
lookup_agent_on_load(agent);* <br>
The flags -agentlib and -agentpath are to run JVMTI
(native) agents, <br>
and Agent_OnLoad is an entrypoint in native agent
library. <br>
So, I'm thinking if it'd make sense to rename the option
to something like below: <br>
AllowArchivingWithJVMTIAgent or <br>
AllowArchivingWithNativeAgent or <br>
AllowArchivingWithAgent <br>
<br>
<br>
<a class="moz-txt-link-freetext"
href="http://cr.openjdk.java.net/%7Eccheung/8201375/webrev.00/src/hotspot/share/memory/filemap.cpp.frames.html"
moz-do-not-send="true">http://cr.openjdk.java.net/%7Eccheung/8201375/webrev.00/src/hotspot/share/memory/filemap.cpp.frames.html</a>
<br>
212 _allow_archiving_with_java_agent =
AllowArchivingWithJavaAgent; ... <br>
1350 if (_allow_archiving_with_java_agent &&
!AllowArchivingWithJavaAgent) { 1351
FileMapInfo::fail_continue("The setting of the
AllowArchivingWithJavaAgent is different " 1352 "from
the setting in the shared archive."); 1353 return false;
1354 } The _allow_archiving_with_java_agent is
initialized with the AllowArchivingWithJavaAgent at
line 212. <br>
</blockquote>
</blockquote>
The assignment at line 212 is for populating the archive
header during CDS dump time. <br>
<blockquote type="cite">
<blockquote type="cite">It is not clear from scratch how
these two values can be different at line 1350. At
least, some comment explaining it is needed. <br>
</blockquote>
</blockquote>
The value retrieved from the archive header could be
different from the run time setting. <br>
I will add a comment. <br>
<br>
<blockquote type="cite">
<blockquote type="cite">Thanks, <br>
Serguei <br>
<br>
<br>
On 11/15/18 10:56, Jiangli Zhou wrote: <br>
<blockquote type="cite">+1 <br>
<br>
Adding serviceability-dev mailing list. It would be
good to have this reviewed by the JVMTI experts also
to make sure all cases are covered. <br>
<br>
Thanks, <br>
<br>
Jiangli <br>
<br>
<br>
On 11/15/18 9:29 AM, Ioi Lam wrote: <br>
<blockquote type="cite">Hi Calvin, <br>
<br>
The changes look good. <br>
<br>
Thanks <br>
<br>
- Ioi <br>
<br>
On 11/14/18 4:40 PM, Calvin Cheung wrote: <br>
<blockquote type="cite">bug: <a
class="moz-txt-link-freetext"
href="https://bugs.openjdk.java.net/browse/JDK-8201375"
moz-do-not-send="true">https://bugs.openjdk.java.net/browse/JDK-8201375</a>
<br>
<br>
webrev: <a class="moz-txt-link-freetext"
href="http://cr.openjdk.java.net/%7Eccheung/8201375/webrev.00/"
moz-do-not-send="true">http://cr.openjdk.java.net/~ccheung/8201375/webrev.00/</a>
<br>
<br>
This change is for adding a diagnostic vm option
(AllowArchivingWithJavaAgent) to allow the
-javaagent in the command line during CDS dumping.
Please refer to the corresponding CSR (<a
class="moz-txt-link-freetext"
href="https://bugs.openjdk.java.net/browse/JDK-8213813"
moz-do-not-send="true">https://bugs.openjdk.java.net/browse/JDK-8213813</a>)
for details. <br>
<br>
Testing: ran hs-tier{1,2,3} tests through mach5. <br>
<br>
thanks, <br>
Calvin <br>
</blockquote>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>