Skip to content

8304438: jcmd JVMTI.agent_load should obey EnableDynamicAgentLoading#14244

Closed
sspitsyn wants to merge 11 commits intoopenjdk:masterfrom
sspitsyn:br38
Closed

8304438: jcmd JVMTI.agent_load should obey EnableDynamicAgentLoading#14244
sspitsyn wants to merge 11 commits intoopenjdk:masterfrom
sspitsyn:br38

Conversation

@sspitsyn
Copy link
Contributor

@sspitsyn sspitsyn commented May 31, 2023

The VM option EnableDynamicAgentLoading was added in JDK 9, default true, to allow deployment to choose whether to allow agents to be loaded/started in the VM. The VM option does the right thing for tools using the Attach API but jcmd JVMTI.agent_load was missed. This should be fixed to disallow loading JVMTI agents when the EnableDynamicAgentLoading is false.

The CSR is:
JDK-8309250: jcmd JVMTI.agent_load should obey EnableDynamicAgentLoading

Testing:

  • run new test test/jdk/sun/tools/jcmd/TestJcmdNoAgentLoad.java
  • TBD: submit mach5 tiers 1-5 to make sure no new regressions are introduced

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8309250 to be approved

Issues

  • JDK-8304438: jcmd JVMTI.agent_load should obey EnableDynamicAgentLoading
  • JDK-8309250: jcmd JVMTI.agent_load should obey EnableDynamicAgentLoading (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/14244/head:pull/14244
$ git checkout pull/14244

Update a local copy of the PR:
$ git checkout pull/14244
$ git pull https://git.openjdk.org/jdk.git pull/14244/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14244

View PR using the GUI difftool:
$ git pr show -t 14244

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/14244.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented May 31, 2023

👋 Welcome back sspitsyn! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Pull request is ready for review label May 31, 2023
@openjdk
Copy link

openjdk bot commented May 31, 2023

@sspitsyn The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot-runtime
  • serviceability

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added serviceability serviceability-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels May 31, 2023
@mlbridge
Copy link

mlbridge bot commented May 31, 2023

@AlanBateman
Copy link
Contributor

/label remove core-libs

@openjdk openjdk bot removed the core-libs core-libs-dev@openjdk.org label May 31, 2023
@openjdk
Copy link

openjdk bot commented May 31, 2023

@AlanBateman
The core-libs label was successfully removed.

@AlanBateman
Copy link
Contributor

AlanBateman commented May 31, 2023

For the "load" command implemented in attachListener, do you remember why EnableDynamicAgentLoading is checked in attach_listener_thread_entry? Looking at it now, I wonder why the check isn't in load_agent. The code in attach_listener_thread_entry shouldn't have to special-case commands.

@sspitsyn
Copy link
Contributor Author

Thank you for the comment.
I was also thinking if this check has to be done in one place.

@AlanBateman
Copy link
Contributor

I was also thinking if this check has to be done in one place.

Yes, maybe JvmtiAgentList::load_agent, JvmtiAgent::load, or invoke_Agent_OnAttach. As part of the change to emit a warning when agent code is loaded into a running VM, invoke_Agent_OnAttach needs to check if EnableDynamicAgentLoading has been set on the command line, so looking at this VM option in one place would be nice.

@sspitsyn
Copy link
Contributor Author

Yes, maybe JvmtiAgentList::load_agent, JvmtiAgent::load, or invoke_Agent_OnAttach. As part of the change to emit a warning when agent code is loaded into a running VM, invoke_Agent_OnAttach needs to check if EnableDynamicAgentLoading has been set on the command line, so looking at this VM option in one place would be nice.

I've moved the EnableDynamicAgentLoading check to the invoke_Agent_OnAttach.
It is the same place where a warning is going to be generated as part of the 8307478 (JEP enhancement).

@dholmes-ora
Copy link
Member

A change in behaviour like this requires a CSR request - the code has been doing the wrong thing for a long time now!

/csr needed

@openjdk openjdk bot added the csr Pull request needs approved CSR before integration label Jun 1, 2023
@openjdk
Copy link

openjdk bot commented Jun 1, 2023

@dholmes-ora has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@sspitsyn please create a CSR request for issue JDK-8304438 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

@sspitsyn
Copy link
Contributor Author

sspitsyn commented Jun 1, 2023

A change in behaviour like this requires a CSR request - the code has been doing the wrong thing for a long time now!

Thank you for the comment. It was not fully clear if a CSR is needed in this case.
Created CSR (it is listed in the PR description).

Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Except for the possible addition of some comments regarding what is meant by "loaded", the changes look good.

Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, previous comment was for another review.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Jun 1, 2023
Copy link
Contributor

@plummercj plummercj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@openjdk
Copy link

openjdk bot commented Jun 2, 2023

@sspitsyn This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8304438: jcmd JVMTI.agent_load should obey EnableDynamicAgentLoading

Reviewed-by: cjplummer, alanb, amenkov

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jun 2, 2023
Copy link
Contributor

@AlanBateman AlanBateman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementation change looks fine. Once your branch is sync up to main line then it should mean EnableDynamicAgentLoading is only used in one function, so easy to understand.

@sspitsyn
Copy link
Contributor Author

sspitsyn commented Jun 5, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Jun 6, 2023

Going to push as commit 4b15349.
Since your change was applied there has been 1 commit pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 6, 2023
@openjdk openjdk bot closed this Jun 6, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 6, 2023
@openjdk
Copy link

openjdk bot commented Jun 6, 2023

@sspitsyn Pushed as commit 4b15349.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@sspitsyn sspitsyn deleted the br38 branch June 6, 2023 00:03
@sspitsyn
Copy link
Contributor Author

sspitsyn commented Jun 6, 2023

Alan, Chris and Alex, thank you for review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hotspot-runtime hotspot-runtime-dev@openjdk.org integrated Pull request has been integrated serviceability serviceability-dev@openjdk.org

Development

Successfully merging this pull request may close these issues.

5 participants