-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Paths to Param Files in Command Lines Refer to Host Execroot Paths (instead of sandbox execroot paths) With --incompatible_sandbox_hermetic_tmp=true
#20515
Comments
Thanks for the highly detailed report! I will look into this tomorrow. Cc @lberki |
Woah, that was a very detailed report, thanks for investing the time and energy into it :) It helped me to zero in on the problem: I can reproduce this. It's due to this snippet:
It doesn't recognize |
The good news is that this tiny patch:
fixes the issue with the params files. The bad news is that it's still not working, but the deploy jar creation (which is the action that fails for me) now fails with a different error. I probably won't have time to debug this any further today. |
Reproduction:
|
@fmeum I think you're right -- I didn't get even far enough to find out that the missing file is a symlink but it indeed is. |
BTW: I'm running it either this issue or a very similar one showing up when
Every path starting with
|
@bazel-io flag |
@bazel-io fork 7.1.0 |
@iancha1992 Forget to say that we should really have this target 7.0.1 - maybe not the full fix, but something that makes the default configuration work with it. |
…sted themselves when the output base was under `/tmp`: 1. Virtual action inputs didn't work. This was a fairly simple omission in the path transformation logic. 2. Artifacts which are resolved symlinks (i.e. declared using `declare_file`) did not work. This is fixed by keeping track of the realpath of the symlink in `FileArtifactValue` / `TreeArtifactValue`. Fixes bazelbuild#20515 and bazelbuild#20518. RELNOTES: None. PiperOrigin-RevId: 595145191 Change-Id: I833025928374c78bc719d8e3be1efb2b2950b9f1
…sted themselves when the output base was under `/tmp`: 1. Virtual action inputs didn't work. This was a fairly simple omission in the path transformation logic. 2. Artifacts which are resolved symlinks (i.e. declared using `declare_file`) did not work. This is fixed by keeping track of the realpath of the symlink in `FileArtifactValue` / `TreeArtifactValue`. Fixes bazelbuild#20515 and bazelbuild#20518. RELNOTES: None. PiperOrigin-RevId: 595145191 Change-Id: I833025928374c78bc719d8e3be1efb2b2950b9f1
…manifested themselves when the output base was under /tmp (#20718) 1. Virtual action inputs didn't work. This was a fairly simple omission in the path transformation logic. 2. Artifacts which are resolved symlinks (i.e. declared using `declare_file`) did not work. This is fixed by keeping track of the realpath of the symlink in `FileArtifactValue` / `TreeArtifactValue`. Fixes #20515 and #20518. RELNOTES: None. Commit fb6658c PiperOrigin-RevId: 595145191 Change-Id: I833025928374c78bc719d8e3be1efb2b2950b9f1 Co-authored-by: Googler <[email protected]>
…sted themselves when the output base was under `/tmp`: 1. Virtual action inputs didn't work. This was a fairly simple omission in the path transformation logic. 2. Artifacts which are resolved symlinks (i.e. declared using `declare_file`) did not work. This is fixed by keeping track of the realpath of the symlink in `FileArtifactValue` / `TreeArtifactValue`. Fixes bazelbuild#20515 and bazelbuild#20518. RELNOTES: None. PiperOrigin-RevId: 595145191 Change-Id: I833025928374c78bc719d8e3be1efb2b2950b9f1
…manifested themselves when the output base was under /tmp (#20766) 1. Virtual action inputs didn't work. This was a fairly simple omission in the path transformation logic. 2. Artifacts which are resolved symlinks (i.e. declared using `declare_file`) did not work. This is fixed by keeping track of the realpath of the symlink in `FileArtifactValue` / `TreeArtifactValue`. Fixes #20515 and #20518. RELNOTES: None. Commit fb6658c PiperOrigin-RevId: 595145191 Change-Id: I833025928374c78bc719d8e3be1efb2b2950b9f1 Co-authored-by: Googler <[email protected]>
A fix for this issue has been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks! |
Issue
Building Bazel at HEAD with Bazel 7.0.0 (with
--incompatible_sandbox_hermetic_tmp=true
, as is the default in Bazel 7) and an output base on/tmp
yields the following error about a.params
file not being found:If
--incompatible_sandbox_hermetic_tmp=false
is passed, the above command succeeds.Details
Running with
--sandbox_debug
produces the following:Click to expand
Inspecting the mounts and their ordering above confirms that contents in Bazel source roots and execroot should be visible: these mounts are bind mounted into the hermetic tmp location (not
/tmp
directly) before/tmp
is pivoted to the hermetic tmp location (the finalbind mount:
in the above).By altering the
linux-sandbox
invocation above we can confirm that thebazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params
file is a dangling symlink, within the sandbox:Inspecting
bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/analysis/libanalysis_cluster-hjar.jar-0.params
within this action's execroot (/tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/sandbox/linux-sandbox/3031/execroot/
) confirms that the file is a symlink that refers to the host's execroot path rather than that of the sandbox (i.e./tmp/bazel-execroot/
):(note how the other files in the above are symlinks to
/tmp/bazel-execroot/
)Cause
Poking around a bit, I think this is the relevant part of
rules_java
:bazel/src/main/java/com/google/devtools/build/lib/rules/java/JavaHeaderCompileAction.java
Lines 486 to 489 in 379ee5f
Notably
rules_cc
generated param files for link actions do not seem to have this issue (note the/tmp/bazel-execroot
in the destinations):I think that's because
rules_cc
generates its param files (for link actions) on its own using separate actions + files that are added as dependencies and doesn't use theCommandLines.Builder
machinery:bazel/src/main/java/com/google/devtools/build/lib/rules/cpp/CppLinkActionBuilder.java
Lines 950 to 971 in 0aacc74
I am not familiar with this part of the Bazel codebase but it seems likely the problematic bit (placing host-execroot paths for the params file onto the command line) lives here:
bazel/src/main/java/com/google/devtools/build/lib/actions/CommandLines.java
Lines 121 to 154 in 29f1db2
And here:
bazel/src/main/java/com/google/devtools/build/lib/analysis/actions/SpawnAction.java
Lines 348 to 360 in 41ca39a
(note the use of
getPrimaryOutput().getExecPath()
forparamFileBasePath
)The text was updated successfully, but these errors were encountered: