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

"I/O exception during sandboxed execution" "Directory not empty" with --experimental_reuse_sandbox_directories #19935

Closed
jfirebaugh opened this issue Oct 25, 2023 · 7 comments
Assignees
Labels
P1 I'll work on this now. (Assignee required) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug

Comments

@jfirebaugh
Copy link

Description of the bug:

--experimental_reuse_sandbox_directories can produce non-hermetic behavior when attempting to reuse a sandbox stash that contains a directory where a file is needed.

Which category does this issue belong to?

Core

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Minimal example: https://github.com/jfirebaugh/bazel_experimental_reuse_sandbox_directories_bug

Clone this repository, and run bazel build --repo_env=CREATE_DIRECTORY=1 --experimental_reuse_sandbox_directories genrule followed by bazel build --repo_env=CREATE_DIRECTORY=0 --experimental_reuse_sandbox_directories genrule (the only difference between the two is the CREATE_DIRECTORY value). The second command will fail with:

ERROR: <workspace>/BUILD.bazel:1:8: Executing genrule //:genrule failed: I/O exception during sandboxed execution: <output_base>/sandbox/darwin-sandbox/18/execroot/__main__/external/repository/output (Directory not empty)

If the second command is modified to remove the use of --experimental_reuse_sandbox_directories, then it succeeds. It also succeeds if you delete the sandbox stash (rm -rf "$(bazel info output_base)/sandbox/sandbox_stash").

Which operating system are you running Bazel on?

macOS

What is the output of bazel info release?

release 6.4.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

n/a

Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.

No

Have you found anything relevant by searching the web?

No

Any other information, logs, or outputs that you want to share?

No response

@jfirebaugh
Copy link
Author

This reproduces with 7.0.0-pre.20231011.2.

@Pavank1992 Pavank1992 added the team-Core Skyframe, bazel query, BEP, options parsing, bazelrc label Oct 25, 2023
@jsharpe
Copy link
Contributor

jsharpe commented Oct 25, 2023

We've also been hitting this with 6.4.0

@oquenchil oquenchil added P1 I'll work on this now. (Assignee required) team-Local-Exec Issues and PRs for the Execution (Local) team and removed untriaged team-Core Skyframe, bazel query, BEP, options parsing, bazelrc labels Oct 25, 2023
@oquenchil oquenchil self-assigned this Oct 25, 2023
@oquenchil
Copy link
Contributor

oquenchil commented Oct 25, 2023

I thought this was related to d6c79db but it's more likely to be unrelated. Could you please try to reproduce with Bazel head?

@oquenchil
Copy link
Contributor

@keertk When was 7.0 cut? I thought it would be after the 13th of October, is d6c79db in 7.0?

@oquenchil
Copy link
Contributor

I'm more convinced now that this is a separate bug not fixed by that PR but I will need to investigate further.

@oquenchil
Copy link
Contributor

@bazel-io fork 7.0.0

bazel-io pushed a commit to bazel-io/bazel that referenced this issue Oct 26, 2023
bazelbuild#19935 gives a clear repro. The problem appears when a stashed sandbox
contains a directory whose same path is a regular file in a later
execution. If we try to reuse the stashed sandbox we trigger an error if
the old directory contained any files.

This was due to simply calling delete() without checking first if it
was a directory. The fix is to call deleteTree() instead in those cases.
directory.

Fixes bazelbuild#19935

RELNOTES:none
PiperOrigin-RevId: 576889004
Change-Id: I73b145cd574b83c473ffaccd90b675eb5f086c0e
iancha1992 pushed a commit that referenced this issue Oct 30, 2023
…ty" with `--experimental_reuse_sandbox_directories` (#19959)

#19935 gives a clear repro. The problem appears when a stashed sandbox
contains a directory whose same path is a regular file in a later
execution. If we try to reuse the stashed sandbox we trigger an error if
the old directory contained any files.

This was due to simply calling delete() without checking first if it
was a directory. The fix is to call deleteTree() instead in those cases.
directory.

Fixes #19935

RELNOTES:none
Commit
7d87996

PiperOrigin-RevId: 576889004
Change-Id: I73b145cd574b83c473ffaccd90b675eb5f086c0e

Co-authored-by: Googler <[email protected]>
@iancha1992
Copy link
Member

A fix for this issue has been included in Bazel 7.0.0 RC5. Please test out the release candidate and report any issues as soon as possible. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P1 I'll work on this now. (Assignee required) team-Local-Exec Issues and PRs for the Execution (Local) team type: bug
Projects
None yet
Development

No branches or pull requests

6 participants