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 it self #10430
Conversation
👋 Welcome back dsamersoff! A progress list of the required criteria for merging this PR into |
@dsamersoff The following labels 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 lists. If you would like to change these labels, use the /label pull request command. |
Sorry @dsamersoff but I don't understand how this arises - can you explain in more detail please? I'm not seeing the connection between setting |
Linker reads LD_LIBRARY_PATH only once, at the time of program loading, so if for some reason launcher need to update LD_LIBRARY_PATH, it creates a new environment and re-launch it self using execvp(). But the launcher is designed so that the decision to re-launch is made after all arguments from all sources have already been processed and copied to the argv array. |
Can't we just remove |
Unfortunately not. |
Sorry Dmitry I'm still trying to get my head around the big picture here. The launcher startup process is extremely complex but also quite sophisticated so I'm a bit surprised this issue exists (and that we have not noticed it before!). I have an impression that the intent if we re-exec is that the env var options have already been processed and so the newly exec'd I'm also struggling to understand under what conditions, exactly, we will re-exec when the data-model selection is no longer an issue. |
I think I agree with David that the JBS issue or PR needs a better description of the issue. It reads to me that this is caused by setting LD_LIBRARY_PATH to find a libjvm that is coming from somewhere else, is that right? |
Years back, I worked on maintaining the launcher. Previously the launcher could re-exec to change data model (e.g. change from 32 to 64 bit on a Solaris environment that supported both options) and to pick a different version. IIRC, both features were dropped so I would also need some additional context and explanation as it what is being attempted here. |
I updated description in the CR, https://bugs.openjdk.org/browse/JDK-8293806 but for convenience copy it here. Also, I added some debug output to the comments for CR Under some circumstances, the launcher have to update LD_LIBRARY_PATH, but the runtime linker only considers this variable during application startup, so after updating LD_LIBRARY_PATH the launcher must re-execute it self by calling execvp(). The decision to re-launch is made after all options from all sources (JDK_JAVA_OPTIONS, @argfile) already been processed and copied to argv[] array. Thus, parameters passed through JDK_JAVA_OPTIONS variable are processed twice. If an option cannot be accepted twice (e.g., -agentlib), the application fails to start. We cannot just remove the JDK_JAVA_OPTIONS variable because some applications (e.g. IDEs) use it to pass user parameters through the chain of child java processes. It happens under following conditions:
|
I'm still somewhat perplexed as the launcher appears to to try and deal with this as I said before "see JLI_AddArgsFromEnvVar and the use of the relaunch field". So something seems amiss here. If that logic is not supposed to deal with the current problem, then what exactly is it intended for? |
The code, that set relaunch variable (see above) doesn't really work. Because at the point (below) when the function is executed the number of arguments is always 1.
|
Then can we fix the use of |
It's exactly what I'm trying to do - fix the broken logic around relaunch variable. We have couple of options here:
|
I don't think solution #2 is desirable whilst the broken re-launch logic remains in place - but I might be swayed to defer that code removal to a separate RFE. That said solution #1 is certainly preferable as there was obviously an intent that relaunch was handled correctly. Happy to hear other opinions. |
@dsamersoff This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 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! |
Take the approach to re-launch as early as possible. |
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.
The fix adds one additional argument - orig_argv to JLI_Launch() and use it in on relaunch in execv() call.
All relevant jtreg tests are passed.
Progress
Issue
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/10430/head:pull/10430
$ git checkout pull/10430
Update a local copy of the PR:
$ git checkout pull/10430
$ git pull https://git.openjdk.org/jdk pull/10430/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 10430
View PR using the GUI difftool:
$ git pr show -t 10430
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/10430.diff