Skip to content

8339289: Enhance Attach API to support arbitrary length arguments - Windows #20782

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from

Conversation

alexmenkov
Copy link

@alexmenkov alexmenkov commented Aug 30, 2024

The fix improves Attch API protocol and implements updated protocol on windows; shared code is ready to implement updated protocol support on other platforms.
More detailed explanations on the 1st comment.

Testing: tier1,tier2,tier3,tier4,hs-tier5-svc
manually tested backward compatibility (old tools can attach to current VMs, current tools can attach to older VMs) on Windows with jdk21u and jdk8u.


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

Issue

  • JDK-8339289: Enhance Attach API to support arbitrary length arguments - Windows (Sub-task - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 20782

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

Using diff file

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

Webrev

Link to Webrev Comment

@alexmenkov
Copy link
Author

Currently Attach API has the following restrictions:

  1. attach operation must have exactly 3 arguments; The value cannot be changed due backward compatibility - tools from previous release should be able to attach to current java processes, current tool should be able to work with older java processes;
  2. each argument is resticted by 1024 symbols; this may be not enough as some arguments contain file paths.

DCmd framework supports any number of command arguments, but encodes all arguments as a single attach operation arguement, so total length of all arguments are restricted by 1024 symbols.

Attach API changes:

  • version of the protocol is bumped to 2; attach operation request v2 contains length of the request, so request can contain any number of argument of arbitrary length (for security reason request length is restricted by 256K);
  • for backward compatibility both client and server sides support both v1 and v2; if v2 is not supported by tool or target JVM, v1 is used for communication;
    new attach operation is implemented: "getVersion"; old VMs report "Operation not recognized", new VMs report supported version;
  • for testing purposes "jdk.attach.compat" system property is introduced to disable v2 protocol;

Windows implementation:
Windows implementation is different from other platforms (other platforms use unix sockets for communications).
On Windows client enqueues operation by copying request parameters and executing remote thread in the target VM process which calls special exported function. Operation results are returned by using pipe (1-directional), created by the client;

  • to enqueue operation v2 new exported function has been added; only pipe name is passed to the target VM for v2 requests;
  • all operation parameters are passed through pipe, operation results are returned through the same pipe (it becomes 2-directional).

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 30, 2024

👋 Welcome back amenkov! 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
Copy link

openjdk bot commented Aug 30, 2024

@alexmenkov 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:

8339289: Enhance Attach API to support arbitrary length arguments - Windows

Reviewed-by: kevinw, sspitsyn

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 768 new commits pushed to the master branch:

  • d1540e2: 8342090: Infer::IncorporationBinaryOp::equals can produce side-effects
  • 7af46a6: 8340554: Improve MessageFormat readObject checks
  • 7d5eefa: 8342862: Gtest added by 8339507 appears to be causing 8GB build machines to hang
  • d8c3b0f: 8342768: GTest AssemblerX86.validate_vm failed: assert(VM_Version::supports_bmi1()) failed: tzcnt instruction not supported
  • 3c14c2b: 8341566: Add Reader.of(CharSequence)
  • b0ac633: 8342075: HttpClient: improve HTTP/2 flow control checks
  • 85774b7: 8342882: RISC-V: Unify handling of jumps to runtime
  • 2c31c8e: 8339730: Windows regression after removing ObjectMonitor Responsible
  • f0b130e: 8339296: Record deconstruction pattern in switch fails to compile
  • e96b4cf: 8342387: C2 SuperWord: refactor and improve compiler/loopopts/superword/TestDependencyOffsets.java
  • ... and 758 more: https://git.openjdk.org/jdk/compare/b711c41d442fc369a84745c0203db638e0b7e671...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this 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
Copy link

openjdk bot commented Aug 30, 2024

⚠️ @alexmenkov This pull request contains merges that bring in commits not present in the target repository. Since this is not a "merge style" pull request, these changes will be squashed when this pull request in integrated. If this is your intention, then please ignore this message. If you want to preserve the commit structure, you must change the title of this pull request to Merge <project>:<branch> where <project> is the name of another project in the OpenJDK organization (for example Merge jdk:master).

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 30, 2024
@openjdk
Copy link

openjdk bot commented Aug 30, 2024

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

  • 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 labels Aug 30, 2024
@mlbridge
Copy link

mlbridge bot commented Aug 30, 2024

Webrevs

@dcubed-ojdk
Copy link
Member

Thanks for putting the details in a separate comment. That will make the emails
that get sent for this PR much shorter.

You use the word symbols, e.g., each argument is resticted by 1024 symbols.
Do you really mean characters or bytes?

@dcubed-ojdk
Copy link
Member

Also thanks for including all the testing info!

@alexmenkov
Copy link
Author

You use the word symbols, e.g., each argument is resticted by 1024 symbols. Do you really mean characters or bytes?

Bytes. The code used char buffers with fixed size.

@alexmenkov
Copy link
Author

Looking for reviewers for the fix

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

This is nice fix, thank you for doing this!
I still need one more pass on the Windows AttachListener part and hope to complete it early next week.

renamed JVM_EnqueueOperation2 to JVM_EnqueueOperation_v2 for consistency (per Serguei request)
Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

I've posted some nits and one questions.
Otherwise, this change looks good to me.
Thank you for the updates.

Copy link
Contributor

@sspitsyn sspitsyn left a comment

Choose a reason for hiding this comment

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

Thank you for the updates. Looks good.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 16, 2024

public static void main(String[] args) throws Exception {
// if the test (client part) in the "compat" mode
boolean clientCompat = "true".equals(System.getProperty("jdk.attach.compat"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Boolean.getBoolean("jdk.attach.compat") ignores case for us as well.
But more generally, are we happy with "jdk.attach.compat" as a boolean flag, or would "jdk.attach.version" be better?
(which is mainly asking if we think there might ever be another version!)

Copy link
Author

Choose a reason for hiding this comment

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

I thought about making the property numeric, but that adds complexity in the logic and I don't think we will need another version soon. Anyway it's internal property for testing only, so we can change it any time.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Oct 24, 2024
@alexmenkov alexmenkov changed the title 8339289: Parameter size mismatch between client and VM sides of the Attach API - Windows 8339289: Enhance Attach API to support arbitrary length arguments - Windows Oct 24, 2024
@openjdk openjdk bot added ready Pull request is ready to be integrated and removed ready Pull request is ready to be integrated labels Oct 24, 2024
@kevinjwalls
Copy link
Contributor

Thanks for updating, looks good. I think it's clearer now that this is not just a Windows-specific fix, but will be an enhancement for all platforms in the long term. Likely argument length is more of a limitation than number of arguments.

Looking back at JDK-8215622: Add dump to file support for jmap –histo
..and that was extending the "inspectheap" attach command, but it should have been using a DiagnosticCommand invoked by jcmd. We may not say it clearly, but the attach api commands are a few basic fundamentals, and most of what we want to implement should be implemented in a DiagnosticCommand.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Oct 24, 2024
@alexmenkov
Copy link
Author

Thank you for review Serguei and Kevin
I'm going to rebase the change and run sanity tests before integration

@alexmenkov
Copy link
Author

/integrate

@openjdk
Copy link

openjdk bot commented Oct 25, 2024

Going to push as commit 36d7173.
Since your change was applied there have been 782 commits pushed to the master branch:

  • ff165f9: 8342934: TYPE_USE annotations printed with error causing "," in toString output
  • 0853aee: 8338426: Test java/nio/channels/Selector/WakeupNow.java failed
  • c202a2f: 8295269: G1: Improve slow startup due to predictor initialization
  • 5cbd578: 8342930: New tests from JDK-8335912 are failing
  • 1e35da8: 8343063: RISC-V: remove redundant reg copy in generate_resolve_blob
  • 4f8f395: 8343060: RISC-V: enable TestFloat16VectorConvChain for riscv
  • a9eb50a: 8342953: RISC-V: Fix definition of RISCV_HWPROBE_EXT_ZVFHMIN
  • 94317db: 8342884: RISC-V: verify float <--> float16 conversion
  • 3c5db12: 8342857: SA: Heap iterator makes incorrect assumptions about TLAB layout
  • 4635351: 8342939: Building ZGC without compiler2 fails
  • ... and 772 more: https://git.openjdk.org/jdk/compare/b711c41d442fc369a84745c0203db638e0b7e671...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Oct 25, 2024

@alexmenkov Pushed as commit 36d7173.

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

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.

4 participants