-
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
ctx.actions.symlink(target_file = ...)
uses absolute paths as destinations, breaking under --incompatible_sandbox_hermetic_tmp=true
+ /tmp/...
output bases
#20518
Comments
Given that issues like this and #20515 exist, can we maybe — for now — disable Alternatively, I think bind mounting the execroot directory to its host path — provided this does not collide with special directories like cc: @fmeum |
Oof, this is pretty bad, I have no idea how this escaped our test battery :( (probably because we don't exercise the case where the output base is under For now, I'll classify this issue as extremely embarrassing but not a fire drill because it only affects people who have their output bases under I don't immediately have any clever ideas how to fix this, other than by running |
@oquenchil do you have any clever ideas here? |
@lberki I remember one of your comments (fmeum@a2fdd4a#r82080580) where you suggested one could dig out the action generating an artifact and downcast it to a concrete action class. Wouldn't this help here? If we could check that the artifact is generated by |
The issue likely isn't exclusive to |
@bazel-io flag |
@bazel-io fork 7.0.1 |
@lberki For Bazel 7.0.1, should we just disable hermetic tmp if the output base lies under |
#20603 is a draft fix for this. |
…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 #20515 and #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
Fixed in fb6658c . |
…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
@bazel-io fork 7.1.0 |
…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.0.1 RC2. Please test out the release candidate and report any issues as soon as possible. Thanks! |
Issue
Another issue like #20515 1: when building Bazel at HEAD with Bazel 7.0.0 and an output base on
/tmp
, I get errors about proto paths when actions forproto_library
targets are run. For example:If
--incompatible_sandbox_hermetic_tmp=false
is passed, the above command succeeds.Details
Running with
--sandbox_debug
and poking around the failing actions execroot reveals that unlike #20515 the file in question here is a symlink into the sandbox-execroot directory (as it should be):However if we follow that symlink (while running under the
sandbox
invocation from--sandbox_debug
) we arrive, once again, at symlink to a host-execroot path:lrwxrwxrwx 1 rrbutani users 105 Dec 12 16:10 /tmp/bazel-execroot/_main/bazel-out/k8-fastbuild/bin/external/protobuf~21.7/_virtual_imports/any_proto/google/protobuf/any.proto -> /tmp/bazel-rrbutani/705c9771f27ae01ebf0993be3b99a716/external/protobuf~21.7/src/google/protobuf/any.proto
Looking at this file (
bazel-out/k8-fastbuild/bin/external/protobuf~21.7/_virtual_imports/any_proto/google/protobuf/any.proto
) in the execroot (note: the actual execroot under the output base, not the action's execroot) corroborates this:Cause
aquery
on@@protobuf~21.7//:any_proto
reveals the action generatingbazel-out/k8-fastbuild/bin/external/protobuf~21.7/_virtual_imports/any_proto/google/protobuf/any.proto
:This then leads back to
proto_library
's starlark implementation function (via_process_srcs
)bazel/src/main/starlark/builtins_bzl/common/proto/proto_library.bzl
Lines 137 to 153 in c519916
... which in turn leads to
SymlinkAction
(via here) which appears to always create symlinks that have absolute path destinations (IIUC):bazel/src/main/java/com/google/devtools/build/lib/analysis/actions/SymlinkAction.java
Lines 189 to 222 in cde4b7b
I am not sure how to go about solving this in a way that's not likely to cause other breakage. As best as I can tell actions are not keyed on
--incompatible_sandbox_hermetic_tmp
; havingctx.actions.symlink
behave differently based on this option seems fraught. If relative symlink destinations are not viable, perhaps we can rewrite these symlinks during sandbox spawn setup? (i.e. instead of making a symlink within the action's execroot that points to the symlink within the execroot, just have the action-execroot symlink point to the destination, adjusted to be sandbox-execroot-relative).Note: #14224 is somewhat related to this though this specific case (
proto_library
) involves an invocation ofctx.actions.symlink(...)
withtarget_file
instead oftarget_path
.Footnotes
in Paths to Param Files in Command Lines Refer to Host Execroot Paths (instead of sandbox execroot paths) With
--incompatible_sandbox_hermetic_tmp=true
#20515, many of the actions were already in my disk cache (with results produced by a previous invocation with--incompatible_sandbox_hermetic_tmp
disabled); this masked other errors like this one ↩The text was updated successfully, but these errors were encountered: