[9.3.0] Close the coverage post-processing FileOutErr before deleting its files - #30678
Open
fmeum wants to merge 1 commit into
Open
[9.3.0] Close the coverage post-processing FileOutErr before deleting its files#30678fmeum wants to merge 1 commit into
FileOutErr before deleting its files#30678fmeum wants to merge 1 commit into
Conversation
…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
marked this pull request as ready for review
August 12, 2026 07:53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
appendCoverageLogcopiescoverage.logandcoverage.errinto the test log and then deletes them, but theFileOutErrthat 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:
The bug is older than that, but it only became reachable for Bazel users with 8e68c24, which flipped
--experimental_split_coverage_postprocessingto default true.Build API Changes
No
Checklist
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 extrawriteOutFile(coverageOutErr.getErrorPath(), coverageOutErr.getOutputPath())call beforeappendCoverageLog. The same four lines were applied at the equivalent positions, withcoverageOutErr.close()placed before that first read of the coverage files.Closes #30663