You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to pass values of ResumeWriterThreshold and PauseWriterThreshold that causes program to hang. There is a check that disallows ResumeWriterThreshold to be greater than PauseWriterThreshold (code), but it doesn't work in case when ResumeWriterThreshold left to default -1 value and PauseWriterThreshold passed explicitly and less than DefaultResumeWriterThreshold. In this case options contains ResumeWriterThreshold that greater than PauseWriterThreshold and writer resume never happens.
Similar situation come when passed ResumeWriterThreshold equal to 0. In this case this check is not true even if _unconsumedBytes is zero and writer is not resumed. Not sure is it lack of validation of wrong options value or bug in code that should work with zero value.
Reproduction Steps
Here is small program that successfully completes with correct values and hangs forever in cases described above
usingSystem.Buffers;usingSystem.IO.Pipelines;usingSystem.Text;//correct values for immediate backpressure// var pipe = new Pipe(new PipeOptions(pauseWriterThreshold: 1, resumeWriterThreshold: 1));//using default resumeWriterThreshold gives incorrect combination of valuesvarpipe=newPipe(newPipeOptions(pauseWriterThreshold:1,resumeWriterThreshold:-1));//with zero resumeWriterThreshold program also hangsvarpipe=newPipe(newPipeOptions(pauseWriterThreshold:1,resumeWriterThreshold:0));varreadTask=Task.Run(async()=>{ReadResultread;do{read=awaitpipe.Reader.ReadAsync();Console.WriteLine($"Read {Encoding.UTF8.GetString(read.Buffer.ToArray())}");pipe.Reader.AdvanceTo(read.Buffer.End);}while(!read.IsCompleted);});varwriteTask=Task.Run(async()=>{awaitpipe.Writer.WriteAsync(Encoding.UTF8.GetBytes("qwerty1"));awaitTask.Delay(100);awaitpipe.Writer.WriteAsync(Encoding.UTF8.GetBytes("qwerty2"));awaitpipe.Writer.CompleteAsync();});awaitTask.WhenAll(readTask,writeTask);
Expected behavior
PipeOptions constructor should throw ArgumentOutOfRangeException for such invalid values
Actual behavior
PipeWriter not resumed after pause
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered:
Hello,
Just wanted to check in to see if anyone was able to review my PR, let me know if there are any questions. Thanks!
ghost
added
in-pr
There is an active PR which will close this issue when it is merged
and removed
in-pr
There is an active PR which will close this issue when it is merged
labels
Jan 27, 2023
ghost
added
in-pr
There is an active PR which will close this issue when it is merged
and removed
in-pr
There is an active PR which will close this issue when it is merged
labels
Oct 16, 2023
Description
It is possible to pass values of ResumeWriterThreshold and PauseWriterThreshold that causes program to hang. There is a check that disallows ResumeWriterThreshold to be greater than PauseWriterThreshold (code), but it doesn't work in case when ResumeWriterThreshold left to default -1 value and PauseWriterThreshold passed explicitly and less than DefaultResumeWriterThreshold. In this case options contains ResumeWriterThreshold that greater than PauseWriterThreshold and writer resume never happens.
Similar situation come when passed ResumeWriterThreshold equal to 0. In this case this check is not true even if _unconsumedBytes is zero and writer is not resumed. Not sure is it lack of validation of wrong options value or bug in code that should work with zero value.
Reproduction Steps
Here is small program that successfully completes with correct values and hangs forever in cases described above
Expected behavior
PipeOptions constructor should throw ArgumentOutOfRangeException for such invalid values
Actual behavior
PipeWriter not resumed after pause
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: