-
Notifications
You must be signed in to change notification settings - Fork 13k
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
BufferedStream<File> doesn't maintain logical position in file with mixed reads/writes #17136
Comments
This has to be decided before 1.0. |
P-backcompat-libs, not 1.0. We already have a separate process for stabilizing the libraries and particular types within them, independent of the 1.0 relaese itself. |
I don't think that I think the best solution here is probably a separate |
Renominating. Are we going to go with this as is? |
we need to decide what we were doing it. (We might mark I-needs-decision, P-high. |
Potentially relevant: a similar abstraction in .NET (https://msdn.microsoft.com/en-us/library/system.io.bufferedstream%28v=vs.110%29.aspx). |
As pointed out in rust-lang#17136 the semantics of a `BufStream` aren't always what one expects, and it looks like other [languages like C#][c-sharp] implement a buffered stream with only one underlying buffer. For now this commit destabilizes the primitive in the `std::io` module to give us some more time in figuring out what to do with it. [c-sharp]: https://msdn.microsoft.com/en-us/library/system.io.bufferedstream%28v=vs.110%29.aspx [breaking-change]
As pointed out in #17136 the semantics of a `BufStream` aren't always what one expects, and it looks like other [languages like C#][c-sharp] implement a buffered stream with only one underlying buffer. For now this commit destabilizes the primitive in the `std::io` module to give us some more time in figuring out what to do with it. [c-sharp]: https://msdn.microsoft.com/en-us/library/system.io.bufferedstream%28v=vs.110%29.aspx [breaking-change]
As pointed out in rust-lang#17136 the semantics of a `BufStream` aren't always what one expects, and it looks like other [languages like C#][c-sharp] implement a buffered stream with only one underlying buffer. For now this commit destabilizes the primitive in the `std::io` module to give us some more time in figuring out what to do with it. [c-sharp]: https://msdn.microsoft.com/en-us/library/system.io.bufferedstream%28v=vs.110%29.aspx [breaking-change]
As pointed out in rust-lang#17136 the semantics of a `BufStream` aren't always what one expects, and it looks like other [languages like C#][c-sharp] implement a buffered stream with only one underlying buffer. For now this commit destabilizes the primitive in the `std::io` module to give us some more time in figuring out what to do with it. [c-sharp]: https://msdn.microsoft.com/en-us/library/system.io.bufferedstream%28v=vs.110%29.aspx [breaking-change]
We ended up deprecating/removing |
Here's an example:
This prints
and afterwards the file contains the string
123456789xyz
even though logically the write happens between the two reads and should have moved the file position over the345
without them being returned from read calls instead of appending to the end (or overwriting the wrong bytes if a tiny buffer size is chosen). This makes the buffering leak through the abstraction where a mostly equivalent C program maintains the illusion:printing
and leaving the file to contain
12xyz6789
. strace suggests glibc just seems to seek backwards (lseek(3, -7, SEEK_CUR)
) before the write presumably for the length of the discarded read buffer or otherwise manually keeping track of the logical file position.The text was updated successfully, but these errors were encountered: