Skip to content

Fixes #62167. WriteAsync may truncate data if called after .Advance(int) #62306

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2021

Conversation

Kuinox
Copy link
Contributor

@Kuinox Kuinox commented Dec 3, 2021

Fixes #62167.
It took me way too much time to pinpoint where this issue came from ^^'.

@ghost ghost added area-System.IO.Pipelines community-contribution Indicates that the PR has been added by a community member labels Dec 3, 2021
Copy link
Member

@halter73 halter73 left a comment

Choose a reason for hiding this comment

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

Great find!

@halter73
Copy link
Member

halter73 commented Dec 3, 2021

While this is an unusual writing pattern, it is valid. You can get corrupted data without this fix. We should service this.

@danmoseley
Copy link
Member

thanks @Kuinox !

@Kuinox
Copy link
Contributor Author

Kuinox commented Dec 3, 2021

While this is an unusual writing pattern

I use this pattern to write an user provided buffer.
In the first part, I write the small packet header, then I call WriteAsync to write the user data.

Copy link
Member

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

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

Old bug it seems!

@BrennanConroy BrennanConroy merged commit e4faf19 into dotnet:main Dec 3, 2021
@BrennanConroy
Copy link
Member

Thanks a lot @Kuinox!

@BrennanConroy
Copy link
Member

/backport to release/6.0

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2021

Started backporting to release/6.0: https://github.com/dotnet/runtime/actions/runs/1536724263

@BrennanConroy
Copy link
Member

/backport to release/5.0

@github-actions
Copy link
Contributor

github-actions bot commented Dec 3, 2021

Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/1536755422

@Kuinox
Copy link
Contributor Author

Kuinox commented Dec 4, 2021

Thanks everyone !

@davidfowl
Copy link
Member

Thank you!

@ghost ghost locked as resolved and limited conversation to collaborators Jan 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.IO.Pipelines community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling Pipe.Writer.WriteAsync after Pipe.Writer.Advance flush truncated data to the PipeReader.
5 participants