Skip to content

Fix leaks and data loss when user filter leaves buckets on input brigade - #24146

Open
bukka wants to merge 1 commit into
php:PHP-8.4from
bukka:stream_filter_user_unconsumed_buckets
Open

bukka wants to merge 1 commit into
php:PHP-8.4from
bukka:stream_filter_user_unconsumed_buckets

Conversation

@bukka

@bukka bukka commented Oct 5, 2026

Copy link
Copy Markdown
Member

The callers expect the input brigade to be empty when the filter returns, so buckets left on it leaked. Buckets put back with PSFS_FEED_ME to be seen again with the next data are now kept by the user filter and prepended to its input on the next call, which also fixes them aliasing the read chunk buffer, being re-filtered by preceding filters in a chain and being lost on the write path. Leftover buckets on any other status, or on the closing call, are released with the existing warning.

This is alternative to #20058

The callers expect the input brigade to be empty when the filter returns,
so buckets left on it leaked. Buckets put back with PSFS_FEED_ME to be seen
again with the next data are now kept by the user filter and prepended to
its input on the next call, which also fixes them aliasing the read chunk
buffer, being re-filtered by preceding filters in a chain and being lost
on the write path. Leftover buckets on any other status, or on the closing
call, are released with the existing warning.

Closes phpGH-20058

Co-authored-by: Nora Dossche <7771979+ndossche@users.noreply.github.com>
Co-authored-by: Matthias Goergens <matthias.goergens@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant