Skip to content

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

Merged
BrennanConroy merged 1 commit into
dotnet:mainfrom
Kuinox:master
Dec 3, 2021
Merged

Fixes #62167. WriteAsync may truncate data if called after .Advance(int)#62306
BrennanConroy merged 1 commit into
dotnet:mainfrom
Kuinox:master

Conversation

@Kuinox

Copy link
Copy Markdown
Contributor

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

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

@halter73halter73 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great find!

@halter73

halter73 commented Dec 3, 2021

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor

thanks @Kuinox !

@Kuinox

Copy link
Copy Markdown
ContributorAuthor

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.

@davidfowldavidfowl left a comment

Copy link
Copy Markdown
Member

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:mainDec 3, 2021
@BrennanConroy

Copy link
Copy Markdown
Member

Thanks a lot @Kuinox!

@BrennanConroy

Copy link
Copy Markdown
Member

/backport to release/6.0

@github-actions

Copy link
Copy Markdown
Contributor

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

@BrennanConroy

Copy link
Copy Markdown
Member

/backport to release/5.0

@github-actions

Copy link
Copy Markdown
Contributor

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

@Kuinox

Copy link
Copy Markdown
ContributorAuthor

Thanks everyone !

@davidfowl

Copy link
Copy Markdown
Member

Thank you!

@ghostghost locked as resolved and limited conversation to collaborators Jan 7, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.IO.Pipelinescommunity-contributionIndicates 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

@Kuinox@halter73@danmoseley@BrennanConroy@davidfowl