Repository navigation
Fix GH-25959: "consumed" stream filter loses or repeats data - #25966
Open
ArtUkrainskiy wants to merge 1 commit into
Open
ArtUkrainskiy wants to merge 1 commit into
ArtUkrainskiy wants to merge 1 commit into
Conversation
On its final flush, at the end of the stream or on stream_filter_remove(), the filter seeked the stream it is attached to. In 8.4 and 8.5 this lost the data: reading a whole file through the filter returned an empty string. Since 8.6 the seek is rejected with a warning. When the first chunk already ends the stream, the seek goes to the start: it rewinds the stream and resets the filter, so the data is read again, and with two consumed filters the read never ends. Remove the seek. The filter now passes the data through unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes GH-25959
On its final flush,
consumed_filter_filter()seeks the stream it's attached to. That happens when a read reaches the end of the stream, or onstream_filter_remove(). In 8.4 and 8.5 the data is lost.stream_get_contents()on a file through the filter returns an empty string, andfgets()returns no lines. Since 8.6 the seek is rejected with a warning. When the first chunk already ends the stream, the seek goes to the start, and the data comes back twice. With twoconsumedfilters that read never ends.The seek has been there since the filter was added in 2006, and the filter has no tests or docs. I couldn't find a case where the seek does something useful, so this removes it. The filter now passes the data through unchanged.
The test fails without the fix on 8.4 and on 8.6. Stream, filter and file tests pass on 8.4 and 8.6, and the test passes with ASan and ZTS. The code change applies cleanly to 8.5, 8.6 and master.