-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8342995: Enhance Attach API to support arbitrary length arguments - Linux #22223
Conversation
/label add serviceability |
👋 Welcome back amenkov! A progress list of the required criteria for merging this PR into |
@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:
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 614 new commits pushed to the
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 |
@alexmenkov |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good I think. (These are kind of hard to read, or hard to appreciate as a whole!)
VirtualMachineImpl.java and attachListener_PLATFORM.cpp have much in common between platforms, but maybe creating new common base classes is an interesting refactor work with not that much payoff. Plus there are AIX versions that some of us don't build and test (which I think you mentioned elsewhere).
On Windows, attachListener_windows.cpp operations have: assert(opened(), "must be");
...I was wondering if we don't need a similar assert in in src/hotspot/os/posix/attachListener_posix.cpp
But probably the different usage pattern explains that, i.e.
Windows' PipeChannel needs the open() method specifically called, but for Posix it creates the socket on construction.
(so this is fine, just some observations)
Yes, there a lot of common code between platforms and it can be refactored, but it would make the fix much bigger and harder to review.
Right. Most of the AIX code is copy of the posix/linux/macosx implementation, but I have no environment to build/test it, so I changed shared code to not break AIX build.
Right. The assert can be added to posix implementation, but it doesn't make much sense as SocketChannel does not opens the socket, but get it from the caller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks, a couple of other notes here in case it helps anyone.
AttachOperation::write_reply(ReplyWriter * writer, jint result, const char* message, int message_len)
is this only called by the write_reply method that passes message_len as strlen(stream) ?
The new check for len<0 might not really be useful but does no harm.
The existing "char msg[32]" is a buffer used to write the numeric jint result, not the message as the name might suggest.
HotSpotVirtualMachine.java already has writeCommand() that handles VERSION_2, so the Linux VirtualMachineImpl can just call it. Also writeString is already there in HotSpotVirtualMachine, so removal from Linux is a good cleanup.
I'm sure we all want to find time for the future conversation about actually streaming the output rather than passing a single buffer around. 8-)
There are couple calls from
This is old code (similar to deleted from
I'm open for it :) |
|
Did it with the last update |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fix looks good modulo a couple of nits.
// We know the whole request does not exceed buffer_size, | ||
// for v1 also name/arguments should not exceed name_length_max/arg_length_max. | ||
if (strlen(name()) > AttachOperation::name_length_max) { | ||
log_error(attach)("Failed to read request: name is too long"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd suggest to be more specific: "Failed to read request: attach operation name is too long"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is "attach" in the log prefix, so I made it "Failed to read request: operation name is too long"
And updated similar logging for arguments several lines below
@@ -231,6 +235,8 @@ class AttachOperation: public CHeapObj<mtServiceability> { | |||
// complete operation by sending result code and any result data to the client | |||
virtual void complete(jint result, bufferedStream* result_stream) = 0; | |||
|
|||
class ReplyWriter; //forward declaration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The comment should start with a space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Kevin, Serguei, thank you for the review |
Going to push as commit dc71e8c.
Your commit was automatically rebased without conflicts. |
@alexmenkov Pushed as commit dc71e8c. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The fix updates Linux (and server-side of macosx) implementation to support Attach API v2 (shared code and Windows implementation were introduced by #20782)
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) with jdk21 and jdk8.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22223/head:pull/22223
$ git checkout pull/22223
Update a local copy of the PR:
$ git checkout pull/22223
$ git pull https://git.openjdk.org/jdk.git pull/22223/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22223
View PR using the GUI difftool:
$ git pr show -t 22223
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22223.diff
Using Webrev
Link to Webrev Comment