-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
8286694: Incorrect argument processing in java launcher #8694
Conversation
👋 Welcome back ysuenaga! A progress list of the required criteria for merging this PR into |
Webrevs
|
Simply considering the compiler warning shouldn't |
Yeah, I thought that first, but I think better of changing this code because the result (element of In addition, subsequent codes consider this case ( 1633 for (i = 0; i < argc; i++) {
1634 char *arg = argv[i];
1635 if (arg[0] == '-' && arg[1] == 'J') {
1636 if (arg[2] == '\0') {
1637 JLI_ReportErrorMessage(ARG_ERROR3);
1638 exit(1);
1639 }
1640 *nargv++ = arg + 2;
1641 }
1642 } However |
I don't recall what "builtin arguments" means. Can you tell me how we would actually hit this conditions such that we string dup and the null string? Or are you saying this is actually an unreachable case: the check for NULL is always false and the actual string is never null anyway? |
if (JLI_IsTraceLauncher()) { | ||
printf("Empty option: jargv[%d]\n", i); | ||
} |
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'd say this is an error as well - but a developer error rather than end-user.
@dholmes-ora |
You forced me to look at this in depth. The values are set via the build system. In the build system it is impossible to get just -J because the -J is only added as a prefix for an existing string. So basically this is impossible code to reach unless you manually override the build system definition. So as far as I can see this is a classic case where we want an assert.
|
@dholmes-ora Thanks for your comment! We cannot use I can change to "normal" |
@YaSuenag I know this is not hotspot code. Please see existing use of assert in related code i.e. src/java.base/share/native/libjli/args.c |
Sorry I see what you mean, it is just an |
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 fine to me.
Thanks.
@@ -1626,7 +1628,8 @@ TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***parg | |||
for (i = 0; i < jargc; i++) { | |||
const char *arg = jargv[i]; | |||
if (arg[0] == '-' && arg[1] == 'J') { | |||
*nargv++ = ((arg + 2) == NULL) ? NULL : JLI_StringDup(arg + 2); | |||
assert(arg[2] != '\0' && "Invalid JAVA_ARGS or EXTRA_JAVA_ARGS defined by build"); |
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.
Interesting trick.
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.
Since we pass NDEBUG, this assert is disabled in release builds. This is the supposed behavior, right? That we don't do anything on release builds?
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.
Right - that is what I would expect from an assert.
@YaSuenag 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 17 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 |
/integrate |
Going to push as commit 26c7c92.
Your commit was automatically rebased without conflicts. |
GCC 12 reports as following:
The code is here:
It seems to be expected that
NULL
is set to new array for arguments if invalid parameter (-J
only) is passed.However
NULL
in new array for arguments (nargv
) means stop condition for argument processing in below:jargv
in L1627 means builtin arguments which is defined byJAVA_ARGS
orEXTRA_JAVA_ARGS
macro. So it should be ignored and reported it in laucher trace log.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/8694/head:pull/8694
$ git checkout pull/8694
Update a local copy of the PR:
$ git checkout pull/8694
$ git pull https://git.openjdk.java.net/jdk pull/8694/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 8694
View PR using the GUI difftool:
$ git pr show -t 8694
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/8694.diff