Skip to content

Commit b9de3d0

Browse files
authored
Fix Write_DataReadFromDesiredOffset test (#45477)
(Already failing on my goal not to submit PRs while on vacation, but I wanted to help squash this test failure taking out multiple PRs.) Sporadic null reference exceptions were occurring in CI as part of GZipStream.Dispose. The call to writeable.Dispose in the writing task can race with the invisible writeable.Dispose that happens as part of the disposal at the end of the block, due to the earlier using statement. If the writeable.Dispose in the task nulls out the _deflateStream inside of the GZipStream after the implicit Dispose has checked for null but before it calls Dispose on the field, it'll null ref. The fix is simple and something that should have been there anyway: explicitly wait for the writing task to complete, which guarantees the implicit disposal won't race with the explicit one.
1 parent c779d86 commit b9de3d0

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/libraries/Common/tests/Tests/System/IO/StreamConformanceTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,8 @@ public virtual async Task Write_DataReadFromDesiredOffset(ReadWriteMode mode)
18581858

18591859
using StreamReader reader = new StreamReader(readable);
18601860
Assert.Equal("hello", reader.ReadToEnd());
1861+
1862+
await write;
18611863
}
18621864

18631865
[Fact]

0 commit comments

Comments
 (0)