Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix the buffering bug that blocks SDK#51151

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
carlossanlop merged 2 commits intodotnet:mainfromadamsitnik:anotherBufferingBug
Apr 13, 2021

Conversation

@adamsitnik
Copy link
Member

@adamsitnikadamsitnik commentedApr 12, 2021
edited by carlossanlop
Loading

Fixes#51141

I was able to identify the issue (after figuring out which process out of many should be debugged in the SDK repo):

obraz

Write a failing test:

obraz

And provide a fix;

obraz

Some details: it's possible that_writePos == _bufferSize and in such case the next call to any of theWrite methods is supposed to flush the write buffer.

jozkee and antonfirsov reacted with thumbs up emojijozkee reacted with heart emoji
@ghost
Copy link

Tagging subscribers to this area:@carlossanlop
See info inarea-owners.md if you want to be subscribed.

Issue Details

I was able to identify the issue (after figuring out which process out of many should be debugged in the SDK repo):

obraz

Write a failing test:

obraz

And provide a fix;

obraz

Some details: it's possible that_writePos == _bufferSize and in such case the next call to any of theWrite methods is supposed to flush the write buffer.

Author:adamsitnik
Assignees:-
Labels:

area-System.IO

Milestone:6.0.0

stream.WriteByte(0);
writtenBytes.Add(0);

byte[]bytes=newbyte[BufferSize-1];
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth putting something other than zeros in here? So it's distinct from the first byte you wrote

Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't really matter. What matters is that we are attempting to write an 11th character on the stream when the buffer can only hold 10 characters.

danmoseley reacted with thumbs up emoji
Copy link
Member

@jozkeejozkeeApr 12, 2021
edited
Loading

Choose a reason for hiding this comment

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

...and the problem was that the internal buffer is not being reset/flushed when WriteByte is called when this buffer is already full.

Copy link
Member

@jozkeejozkee left a comment

Choose a reason for hiding this comment

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

elseif(_writePos==_bufferSize-1)
else
{
FlushWrite();
Copy link
Member

Choose a reason for hiding this comment

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

So this method should only be called when either _writePos == 0 or _writePos == _bufferSize, right?
Consider adding the assertion, but not in this PR since we want to merge it ASAP.

Suggested change
FlushWrite();
Debug.Assert(_writePos==_bufferSize);
FlushWrite();

@carlossanlopcarlossanlop merged commit4f3fd1a intodotnet:mainApr 13, 2021
@carlossanlopcarlossanlop deleted the anotherBufferingBug branchApril 13, 2021 06:56
@ghostghost locked asresolvedand limited conversation to collaboratorsMay 13, 2021
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@danmoseleydanmoseleydanmoseley left review comments

@jeffhandleyjeffhandleyjeffhandley approved these changes

@jozkeejozkeejozkee approved these changes

+1 more reviewer

@carlossanlopcarlossanlopcarlossanlop approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.0.0

Development

Successfully merging this pull request may close these issues.

Fix test failures found in dotnet/sdk when opting-into the new FileStream strategy mode

5 participants

@adamsitnik@jeffhandley@carlossanlop@danmoseley@jozkee

[8]ページ先頭

©2009-2025 Movatter.jp