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

windows race on cleanup of test dir (Permission denied) #24135

Open
novas0x2a opened this issue Oct 29, 2024 · 4 comments
Open

windows race on cleanup of test dir (Permission denied) #24135

novas0x2a opened this issue Oct 29, 2024 · 4 comments
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug under investigation

Comments

@novas0x2a
Copy link

novas0x2a commented Oct 29, 2024

Description of the bug:

So, to start with, I should say I'm not sure what was supposed to happen here. The circumstance that led to this was my accidentally setting the out parameter of native_test to the same value in two different targets (in the same package); I acknowledge that this is not the correct thing to do :). I was surprised that bazel let me do that without erroring immediately? (This is a copy of another ticket: bazelbuild/bazel-skylib#543)

Which category does this issue belong to?

No response

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

The reproduction is here: https://github.com/novas0x2a/native-test-repro. The repo script is run.sh. The HEAD as I write this is novas0x2a/native-test-repro@761b23c

  • On linux, you can run run.sh and it will loop forever just fine.
  • On windows, it appears to race. After a few successful loops, the loop will terminate with:
INFO: Analyzed 4 targets (0 packages loaded, 0 targets configured).
ERROR: C:/path/native-test-repro/BUILD.bazel:21:12: Testing //:windows-two (run 5 of 5) failed: java.io.IOException: F:/path/execroot/__main__/_tmp/9e1809df2d530d8a813b5d1e35cb82b3 (Permission denied)
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.271s, Critical Path: 0.04s
INFO: 11 processes: 11 internal.
ERROR: Build did NOT complete successfully
//:unix-one                                                             SKIPPED
//:unix-two                                                             SKIPPED
//:windows-one                                                        NO STATUS
//:windows-two                                                        NO STATUS

Executed 0 out of 4 tests: 4 were skipped.

Which operating system are you running Bazel on?

Windows, Ubuntu 22.04

What is the output of bazel info release?

Present in both:

  • release 8.0.0rc2
  • release 7.3.2

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 HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

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

No response

@novas0x2a
Copy link
Author

I wasn't sure how to triage this one

@satyanandak satyanandak added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Oct 30, 2024
@meteorcloudy meteorcloudy added P3 We're not considering working on this, but happy to review a PR. (No assignee) area-Windows Windows-specific issues and feature requests under investigation and removed untriaged labels Nov 5, 2024
@meteorcloudy
Copy link
Member

On Windows, you cannot delete a dir if it's opened by another process, maybe F:/path/execroot/__main__/_tmp/9e1809df2d530d8a813b5d1e35cb82b3 is opened by some binary inside the test?

@novas0x2a
Copy link
Author

note that in the repro, the "test" is just

rem

@tjgq
Copy link
Contributor

tjgq commented Nov 27, 2024

The circumstance that led to this was my accidentally setting the out parameter of native_test to the same value in two different targets (in the same package); I acknowledge that this is not the correct thing to do :). I was surprised that bazel let me do that without erroring immediately?

Bazel will let two rules declare the same output, as long as the actions that produce it are identical in every respect. For native_test, the out parameter is just a symlink to the src file, and since both out and src are the same for both tests, the symlink action also looks the same for both.

On windows, it appears to race.

My theory is that the temporary directory name generated for the test is not unique enough when two tests share the same executable (which, for native_test, is also the out parameter): https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/analysis/test/TestStrategy.java;l=352;drc=3281c8870a6d0b478b46dfe91fc64c7f75553f43

This is a somewhat unusual situation (usually every test target has a unique executable), but admittedly, it's perfectly valid code that we ought to handle correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Windows Windows-specific issues and feature requests P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: bug under investigation
Projects
None yet
Development

No branches or pull requests

6 participants