-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8334169: Long arguments of attach operation are silently truncated on Windows #19780
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
Conversation
👋 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 320 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 The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
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.
The fix looks good. Posted some nits and questions.
|
||
HotSpotVirtualMachine vm = (HotSpotVirtualMachine)VirtualMachine.attach(String.valueOf(app.getPid())); | ||
|
||
if (setFlag(vm)) { |
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.
Q: Should the test fail if there an IOException
was caught in the setFlag()
call?
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.
Currently Attach operations have restriction for argument size, so setFlag() is expected to fail for long values.
This fix adds AttachOperationFailedException for the case on windows, linux/bsd/aix implementations throw generic IOException.
(There is JDK-8334168 to throw AttachOperationFailedException instead of IOException if an argument is too long on other platforms)
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.
Not sure, you've answered my question. Let me ask it differently.
Here I do not care about other exceptions on other platforms.
The setFlag()
can catch an IOException
at the line 126 and return false in that case. The run()
method at the line 94 is swallowing the false
value as there is no else
statement. So, we just ignore the IOException
and do not test anything.
My question is: Why don't we throw a RuntimeException
in the case the setFlag()
returned false
?
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.
Because vm.setFlag
may (and should) throw exception if bad argument is specified.
This is what the issue about - on Windows vm.setFlag
with long argument did not throw exception, but truncated the argument, and successfully executed the command with truncated argument value.
|
||
// Value length exceeds 1K. | ||
Test withLongValue() { | ||
flagValue = generateValue(1024 + 1); |
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.
Shouldn't we also be testing exactly 1024 and expect it to work?
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.
good question!
tried to make it 1024 and it does not work!
Windows VirtualMachineImpl has one more issue - it uses 1024 char buffers, but it should be (1024 + 1) as AttachListener does (1 extra char to 0-terminator), so maximum argument size on windows is 1023.
Will fix it.
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 the issue, also renamed jstring_to_cstring
argument to make it clear that buffer size is expected and updated callers to use sizeof
.
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.
/integrate |
Going to push as commit a60608e.
Your commit was automatically rebased without conflicts. |
@alexmenkov Pushed as commit a60608e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
The change fixes a bug in Attach API implementation on Windows when argument(s) are longer than 1023 bytes
testing: test/hotspot/jtreg/serviceability/attach, test/jdk/com/sun/tools/attach on Oracle supported platforms
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/19780/head:pull/19780
$ git checkout pull/19780
Update a local copy of the PR:
$ git checkout pull/19780
$ git pull https://git.openjdk.org/jdk.git pull/19780/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 19780
View PR using the GUI difftool:
$ git pr show -t 19780
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/19780.diff
Webrev
Link to Webrev Comment