Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Make ReadToEnd static helper resilient against stream.Length changes. #34798

Merged
merged 1 commit into from
Jan 24, 2019

Conversation

ahsonkhan
Copy link

Applying feedback from dotnet/core-setup#5009 (comment) where we were using the ReadToEnd static helper from corefx.

Do you have any suggestions on how to test this? I was trying to get one thread to read from the stream while another changes its length but couldn't get the test to fail since it relies on the timing of the get and set length. Any ideas on how to deterministically test the race condition?

cc @bartonjs, @stephentoub

@ahsonkhan ahsonkhan added this to the 3.0 milestone Jan 24, 2019
@ahsonkhan ahsonkhan self-assigned this Jan 24, 2019
@ahsonkhan ahsonkhan requested a review from stephentoub January 24, 2019 07:59
Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@stephentoub stephentoub merged commit 49109de into dotnet:master Jan 24, 2019
@bartonjs
Copy link
Member

Do you have any suggestions on how to test this?

A custom Stream type (or maybe an existing swiss-army-test-Stream) which claims 900 bytes of Length, then returns 2MB of 0x20, then ends in a 0x33.

@stephentoub
Copy link
Member

stephentoub commented Jan 24, 2019

A custom Stream type (or maybe an existing swiss-army-test-Stream) which claims 900 bytes of Length, then returns 2MB of 0x20, then ends in a 0x33.

Yeah, basically just lie in your custom Stream.Length, e.g. return Length == 1 from a stream that contains a larger document, and validate that you get the document you expected.

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants