bazelbuild / bazelbuild/bazel-skylib

odd behavior with conflicting outputs with native_test on windows

Open
#543 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
444
Forks
202
PR merge metrics
No merged PRs in 30d

Description

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?

With that said, this seems to be triggering a race condition that leads to an odd failure on windows, so I figured I'd report it in case this pathological behavior is triggering a different bug.

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

- 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://native-test-repro/BUILD.bazel:13:12: Testing //:windows-one (run 3 of 5) failed: java.io.IOException: F://kcgnk7y7/execroot/__main__/_tmp/a2722bcc0b9902c7324c6c5148102354 (Permission denied)
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.265s, 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.
```

It appears to be racing on the deletion of the `TEST_TMPDIR`, though I'm not sure about that. Windows doesn't like it when you delete directories that have files in them that another process has open; I assume that's what's happening here.

Contributor guide

Open the contributing guide

Research direction

Start with the external native-test-repro repository at commit 761b23c14c5f6752f3bd5fd990ca9559132ffc30 and run run.sh on Windows and Linux. Inspect BUILD.bazel around line 13 and the native_test targets, then verify whether concurrent use or deletion of TEST_TMPDIR causes the permission failure. Done means the conflicting-output case is handled or clearly rejected without the Windows race.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.