Skip to content
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

Fix calculation of aligned buffer size #16161

Closed
wants to merge 5 commits into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Oct 1, 2024

As is, for requested size which are already aligned, we over-allocate.

This issue has been reported by @kkmuffme.

As is, for requested size which are already aligned, we over-allocate.

This issue has been reported by @kkmuffme.
@cmb69 cmb69 marked this pull request as ready for review October 2, 2024 10:12
@cmb69 cmb69 requested a review from bukka as a code owner October 2, 2024 10:12
Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Looks correct to me. Thanks!

main/php_output.h Outdated Show resolved Hide resolved
@kkmuffme
Copy link

kkmuffme commented Oct 3, 2024

Will this also fix it for the php.ini output_buffering directive, if that has the same issue?

EDIT: will this ship with PHP 8.4? or will it also be backported to earlier PHP versions?

@cmb69
Copy link
Member Author

cmb69 commented Oct 3, 2024

Will this also fix it for the php.ini output_buffering directive, if that has the same issue?

Yes, that uses the same code, so has the same issue, and will be fixed as well.

will this ship with PHP 8.4? or will it also be backported to earlier PHP versions?

Unlikely, since at least in a strict sense, this patch constitutes an ABI break.

@kkmuffme
Copy link

kkmuffme commented Oct 3, 2024

Unlikely, since at least in a strict sense, this patch constitutes an ABI break.

Unlikely that it's backported?
Or unlikely it ships with PHP 8.4?
Or both unlikely?

@kkmuffme
Copy link

kkmuffme commented Oct 3, 2024

Will this also fix it for the php.ini output_buffering directive, if that has the same issue?
Yes, that uses the same code, so has the same issue, and will be fixed as well.

Just to add on to this then to clarify this (and get some feedback if there might be an issue):
for the php.ini directive:
output_buffering=0 => off, behaves like chunk_size 1
output_buffering=1 => on, behaves like chunk_size 0
output_buffering=2 (or higher value) => on, behaves like chunk_size 2 (or higher value)

This might be something that should perhaps be clarified in the docs, as it's an easy mistake to make when switching between .ini and PHP

@cmb69
Copy link
Member Author

cmb69 commented Oct 3, 2024

Or both unlikely?

Both are unlikely; introducing an ABI is already too late for PHP 8.4, so this fix should probably only get into PHP 8.5 (or 9.0, whatever comes next).

Just to add on to this then to clarify this (and get some feedback if there might be an issue): for the php.ini directive: output_buffering=0 => off, behaves like chunk_size 1 output_buffering=1 => on, behaves like chunk_size 0 output_buffering=2 (or higher value) => on, behaves like chunk_size 2 (or higher value)

This might be something that should perhaps be clarified in the docs, as it's an easy mistake to make when switching between .ini and PHP

Oh, good catch! Since there is special handling for 0 and 1

php-src/main/main.c

Lines 1862 to 1863 in 95fa39d

} else if (PG(output_buffering)) {
php_output_start_user(NULL, PG(output_buffering) > 1 ? PG(output_buffering) : 0, PHP_OUTPUT_HANDLER_STDFLAGS);

we should document that.

@cmb69 cmb69 closed this in a1d4595 Oct 9, 2024
@cmb69 cmb69 deleted the cmb/output-alignment branch October 9, 2024 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants