Skip to content
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

8293806: JDK_JAVA_OPTIONS picked up twice if launcher re-executes itself #11538

Closed
wants to merge 3 commits into from
Closed

8293806: JDK_JAVA_OPTIONS picked up twice if launcher re-executes itself #11538

wants to merge 3 commits into from

Conversation

dsamersoff
Copy link

@dsamersoff dsamersoff commented Dec 6, 2022

If the user has set LD_LIBRARY_PATH to use a particular libjvm.so, options from the JDK_JAVA_OPTIONS environment variable are picked up twice.

If an option cannot be accepted twice (e.g., -agentlib), the application fails to start.

The same happens on operating systems that doesn't support $RPATH/$ORIGIN and always have to set LD_LIBRARY_PATH and re-exec the launcher.

This fix takes the approach to re-launch as early as possible, as discussed here:

#10430

This PR consists of three commits:

  1. Cleanup of java_md.c
  2. The implementation of early re-launch
  3. Performance optimization

@AlanBateman, @dholmes-ora Alan, David - any comments are appreciated.


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-8293806: JDK_JAVA_OPTIONS picked up twice if launcher re-executes itself

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 11538

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 6, 2022

👋 Welcome back dsamersoff! 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 openjdk bot added the rfr Pull request is ready for review label Dec 6, 2022
@openjdk
Copy link

openjdk bot commented Dec 6, 2022

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

  • core-libs
  • hotspot-runtime

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 hotspot-runtime hotspot-runtime-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Dec 6, 2022
@mlbridge
Copy link

mlbridge bot commented Dec 6, 2022

Webrevs

@dsamersoff
Copy link
Author

/issue JDK-8293806

@openjdk
Copy link

openjdk bot commented Dec 6, 2022

@dsamersoff This issue is referenced in the PR title - it will now be updated.

@AlanBateman
Copy link
Contributor

I skimmed through the changes and agree there is an issue with options that shouldn't be repeated. I don't think the overall approach is too bad but I suspect it will go through a few iterations. Right now, all LD_LIBRARY_PATH handling is the "unix" java_md.c and I think we should keep it there. I wonder if the SETENV_REQUIRED removal could be split out and done first as that would remove some of the changes and make it easier to understand the impact of the changes.

}
#endif

JLI_SetTraceLauncher();
Copy link
Contributor

Choose a reason for hiding this comment

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

It's confusing to call JLI_SetTraceLauncher here as that is normally done by InitiLauncher.

Copy link
Author

Choose a reason for hiding this comment

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

Agree. Will file a separate CR for java_md.c cleanup.

/* This test has no value on windows */
return;
}
env.put(JDK_JAVA_OPTIONS, "-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005");
Copy link
Contributor

Choose a reason for hiding this comment

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

Tests uses hard coded ports are problematic as they will fail if the port is in used by something else, like another tests running concurrently.

@@ -194,7 +190,8 @@ ContainsLibJVM(const char *env) {
/* to optimize for time, test if any of our usual suspects are present. */
clientPatternFound = JLI_StrStr(env, clientPattern) != NULL;
serverPatternFound = JLI_StrStr(env, serverPattern) != NULL;
if (clientPatternFound == JNI_FALSE && serverPatternFound == JNI_FALSE) {
minimalPatternFound = JLI_StrStr(env, serverPattern) != NULL;
if (clientPatternFound == JNI_FALSE && serverPatternFound == JNI_FALSE && minimalPatternFound == JNI_FALSE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This change (for minimal vm) doesn't seem to be related to re-execing.


#if !defined(WINDOWS) && !defined(MACOSX)
JLI_ReExecLauncher(argc, argv);
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming is problematic here as it looks like it always re-execs on Unix/Linux systems. I think what you are looking for is something like ReExecLauncherIfNeeded or something that make it clear that it doesn't re-exec always.

@dsamersoff dsamersoff marked this pull request as draft December 13, 2022 09:54
@openjdk openjdk bot removed the rfr Pull request is ready for review label Dec 13, 2022
@bridgekeeper
Copy link

bridgekeeper bot commented Feb 7, 2023

@dsamersoff This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@dsamersoff
Copy link
Author

/open

@openjdk
Copy link

openjdk bot commented Feb 15, 2023

@dsamersoff This pull request is already open

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 12, 2023

@dsamersoff This pull request has been inactive for more than 8 weeks and will be automatically closed if another 8 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 7, 2023

@dsamersoff This pull request has been inactive for more than 16 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

@bridgekeeper bridgekeeper bot closed this Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org hotspot-runtime hotspot-runtime-dev@openjdk.org
2 participants