Skip to content

[9.3.0] Close the coverage post-processing FileOutErr before deleting its files - #30678

Open
fmeum wants to merge 1 commit into
bazelbuild:release-9.3.0from
fmeum:cp-9.3.0-30662
Open

[9.3.0] Close the coverage post-processing FileOutErr before deleting its files#30678
fmeum wants to merge 1 commit into
bazelbuild:release-9.3.0from
fmeum:cp-9.3.0-30662

Conversation

@fmeum

@fmeum fmeum commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Description

appendCoverageLog copies coverage.log and coverage.err into the test log and then deletes them, but the FileOutErr that the coverage post-processing spawn wrote them through was never closed. This closes it before the delete, and also closes it on the paths that rethrow, which previously leaked the handles.

Motivation

Deleting a file that still has an open handle is fine on POSIX, but not on Windows. Every affected test then fails with:

ERROR: ... Testing //tests/alwayslink_srcs:alwayslink_test failed: java.io.IOException: C:/b/skckkmg2/execroot/_main/bazel-out/x64_windows-fastbuild/testlogs/tests/alwayslink_srcs/alwayslink_test/coverage.err (Permission denied)

The bug is older than that, but it only became reachable for Bazel users with 8e68c24, which flipped --experimental_split_coverage_postprocessing to default true.

Build API Changes

No

Checklist

  • I have added tests for the new use cases (if any).
  • I have updated the documentation (if applicable).

Release Notes

Closes #30662.

PiperOrigin-RevId: 962724931
Change-Id: Icb52f15e33291676ee7f96a0d2d4b22235bd5536

(cherry picked from commit 53428ca)

9.3.0 adaptation: the release branch does not have master's if (testResultDataBuilder.getTestPassed()) wrapper around the coverage post-processing block and still has an extra writeOutFile(coverageOutErr.getErrorPath(), coverageOutErr.getOutputPath()) call before appendCoverageLog. The same four lines were applied at the equivalent positions, with coverageOutErr.close() placed before that first read of the coverage files.

Closes #30663

…iles (bazelbuild#30662)

### Description

`appendCoverageLog` copies `coverage.log` and `coverage.err` into the test log and then deletes them, but the `FileOutErr` that the coverage post-processing spawn wrote them through was never closed. This closes it before the delete, and also closes it on the paths that rethrow, which previously leaked the handles.

### Motivation

Deleting a file that still has an open handle is fine on POSIX, but not on Windows. Every affected test then fails with:

```
ERROR: ... Testing //tests/alwayslink_srcs:alwayslink_test failed: java.io.IOException: C:/b/skckkmg2/execroot/_main/bazel-out/x64_windows-fastbuild/testlogs/tests/alwayslink_srcs/alwayslink_test/coverage.err (Permission denied)
```

The bug is older than that, but it only became reachable for Bazel users with 8e68c24, which flipped `--experimental_split_coverage_postprocessing` to default true.

### Build API Changes

No

### Checklist

- [ ] I have added tests for the new use cases (if any).
- [ ] I have updated the documentation (if applicable).

### Release Notes

Closes bazelbuild#30662.

PiperOrigin-RevId: 962724931
Change-Id: Icb52f15e33291676ee7f96a0d2d4b22235bd5536

(cherry picked from commit 53428ca)
@fmeum
fmeum marked this pull request as ready for review August 12, 2026 07:53
@fmeum
fmeum requested a review from a team as a code owner August 12, 2026 07:53
@github-actions github-actions Bot added the awaiting-review PR is awaiting review from an assigned reviewer label Aug 12, 2026
@iancha1992
iancha1992 requested a review from pzembrod August 12, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant