-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
8325567: jspawnhelper without args fails with segfault #18112
Conversation
👋 Welcome back elifaslan1! A progress list of the required criteria for merging this PR into |
/contributor add @vpa1977 |
@elifaslan1 |
@elifaslan1 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.
lgtm
System.exit(ERROR + 2); | ||
System.exit(0); |
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.
Its bad form to System.exit from not at the top level. Is that necessary.
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.
This is in line with other tests in this file , e.g. see parentCode()
.
I agree that code would be cleaner if the test is refactored to return error code from the test methods and system.exit() in the main instead, but this might be a separate pr done before or after this one, e.g. something like [1].
[1] vpa1977@7cbbaf4
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.
ok, the same pattern is used consistently.
/reviewers 2 reviewer |
@RogerRiggs |
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 change in jspawnhelper looks good.
I think it would be simpler to have a separate jdk/java/lang/ProcessBuilder/JspawnhelperMisuse.java
test that simply invokes the jspawnhelper
and verifies the proper message is printed. It would be more straightforward than trying to fit the protocol test? Plus, we can test 0, 1, 3, 4 args, not only 0 args in that test, and we can also test 2 args with bad format.
I'm curious why this test is requires |
This is due to the tests of the crash scenarios that are guarded with #ifdef DEBUG in jspawnhelper. Moving the test in the separate file is a great suggestion so that misuse case is added to the release test suite. |
Yes, this makes the test cleaner[1]. Note, we need to make another small change to jspawnhelper to flush the output[2]. [1] vpa1977@ac7b5c1 |
Note that we have
|
Thank you! This shortens things quite a bit[1] [1] bb65fc8 |
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.
So, the test is "passing" with argc == 2
because jspawnhelper shuts down on illegal argv[1]
, right? This is probably fine.
More stylistic comments:
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.
I am good with this version.
Let's see if @RogerRiggs and @vpa1977 have any additional feedback. |
Hi, the changes look good, just a minor note regarding waitFor() removal. OutputAnalyzer/LazyOutputBuffer do not have timeout on waitFor() so in a rare case when jspawnhelper is stuck, the test might block the CI. |
for (int nArgs = 0; nArgs < 10; nArgs++) { | ||
tryWithNArgs(nArgs); |
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.
Running with more than 3 arguments is unnecessary. Yes, its quick but just burns cpu.
When running with 2 arguments, the failure mode is not due to the number of arguments but is because argument 1 is formatted incorrectly; should be "%d:%d:%d"
. Though I supposed this falls into the "incorrect use category".
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.
I wonder if it would make sense to add a test with a correct argument format?
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.
I wonder if it would make sense to add a test with a correct argument format?
I would say that is what current jspawnhelper tests already test, and it is also tested implicitly with Process
tests. Let's keep this test for testing that warning messages are printed on most common cases of misuse -- that is why JspawnhelperWarnings
is a good name.
/* | ||
* @test | ||
* @bug 8325567 | ||
* @requires (os.family == "linux") | (os.family == "aix") |
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.
Unless I'm mistaken, jspawn helper is used on Mac as well.
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.
Yes indeed, it is used for all Unix OSes (that is, everything but Windows).
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.
I think what matters for this test test most is which platforms we build jspawnhelper
for, and those platforms indeed are:
ifeq ($(call isTargetOs, macosx aix linux), true)
$(eval $(call SetupJdkExecutable, BUILD_JSPAWNHELPER, \
So I'd say we just add (os.family == "mac")
here. I would find it a bit weird to ask for os.family != "windows"
, which would implicitly rely on exhaustiveness of current os family types.
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.
Hm, that is not ideal code in the makefile. jspawnhelper
is called from src/java.base/unix/classes/java/lang/ProcessImpl.java
, so it is relied upon for all Unix implementation. Granted, this is currently the same as the list "macosx aix linux", but it would be better to express the same logic in the makefile as in the code.
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.
JDK-8327675 was just integrated, which replaces the build logic for jspawnhelper to check for "unix" instead of enumerating all our unixes. I suggest the same pattern should be used here.
|
||
import java.nio.file.Paths; | ||
import java.util.Arrays; | ||
import java.util.concurrent.TimeUnit; |
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.
Unused import.
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.
LGTM
@elifaslan1 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 83 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@eastig, @RogerRiggs, @shipilev) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
/integrate |
@elifaslan1 |
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.
lgtm
/sponsor |
Going to push as commit 2627470.
Your commit was automatically rebased without conflicts. |
@eastig @elifaslan1 Pushed as commit 2627470. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This change is intended to address the segmentation fault issue that occurs when jspawnhelper is called without arguments,.
There is a new test added to verify the behavior in such cases.
[ec2-user@ip-172-16-0-10 jdk]$ make CONF=linux-x86_64-server-fastdebug test TEST=test/jdk/java/lang/ProcessBuilder/JspawnhelperWarnings.java
Progress
Issue
Reviewers
Contributors
<vpetko@openjdk.org>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/18112/head:pull/18112
$ git checkout pull/18112
Update a local copy of the PR:
$ git checkout pull/18112
$ git pull https://git.openjdk.org/jdk.git pull/18112/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 18112
View PR using the GUI difftool:
$ git pr show -t 18112
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/18112.diff
Webrev
Link to Webrev Comment