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

Allow fallback from runfiles lookup in edge cases #27

Merged
merged 1 commit into from
Nov 5, 2021

Conversation

fmeum
Copy link
Owner

@fmeum fmeum commented Nov 5, 2021

Currently, libjvm_stub exits if the C++ runfiles library detects
runfiles but then fails to find the JDK. This was based on the
assumption that this situation could only occur if e.g. Bazel rules
would improperly forward runfiles.

However, this can also happen when the binary using libjvm_stub is itself
launched from another, top-level binary that does not set the variables
used for runfiles discovery. If the top-level binary uses a runfiles
manifest to find the current binary, it will execute it using a path
that points into the Bazel cache directory. Since the contents of the
cache are not hermetic, an adjacent out-of-date .runfiles directory or
MANIFEST may exist as a left-over from a previous direct run of the
current binary. Since there is no way to detect this scenario, fall back
to a system-provided JDK but print a warning.

Also print all Bazel-related warnings to stderr rather than stdout.

Currently, libjvm_stub exits if the C++ runfiles library detects
runfiles but then fails to find the JDK. This was based on the
assumption that this situation could only occur if e.g. Bazel rules
would improperly forward runfiles.

However, this can also happen when the binary using libjvm_stub is itself
launched from another, top-level binary that does not set the variables
used for runfiles discovery. If the top-level binary uses a runfiles
manifest to find the current binary, it will execute it using a path
that points into the Bazel cache directory. Since the contents of the
cache are not hermetic, an adjacent out-of-date .runfiles directory or
MANIFEST may exist as a left-over from a previous direct run of the
current binary. Since there is no way to detect this scenario, fall back
to a system-provided JDK but print a warning.

Also print all Bazel-related warnings to stderr rather than stdout.
@fmeum fmeum force-pushed the fix-runfiles-lookup branch from 56ed621 to 2735614 Compare November 5, 2021 09:19
@fmeum
Copy link
Owner Author

fmeum commented Nov 5, 2021

@simonresch FYI

@fmeum fmeum merged commit 5a3507d into main Nov 5, 2021
@fmeum fmeum deleted the fix-runfiles-lookup branch November 5, 2021 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant