Skip to content

Fix GH-13817: Segmentation fault for enabled observers after pass 4 - #14018

Closed
bwoebi wants to merge 2 commits into
php:PHP-8.2from
bwoebi:gh13817
Closed

bwoebi wants to merge 2 commits into
php:PHP-8.2from
bwoebi:gh13817

Conversation

@bwoebi

@bwoebi bwoebi commented Apr 20, 2024

Copy link
Copy Markdown
Member

Instead of fixing up temporaries count in between observer steps, just take ZEND_ACC_DONE_PASS_TWO into account during stack_size calculation. Introducing zend_vm_calc_ct_used_stack for that use case.

This should be much less susceptible to forgetting to handle the ZEND_OBSERVER_ENABLED temporary explicitly.

Comment thread Zend/Optimizer/zend_optimizer.c Outdated
Comment on lines 1241 to 1242

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't understand why you decrement and increment op_array->T back and force.
It may be modified only by two Optimizer passes - optimize_temp_vars_5.c and compact_vars.c.
Most probably these passes need to be updated to take OBSERVER into account.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree. I wasn't really aware that only these two passes touch it - that makes much more sense then :-)

@dstogov dstogov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please try to remove all the op_array->T observer related modifications in Optimizer and add incrementation only in optimize_temp_vars_5.c and compact_vars.c

Instead of fixing up temporaries count in between observer steps, just take ZEND_ACC_DONE_PASS_TWO into account during stack_size calculation.
Introducing zend_vm_calc_ct_used_stack for that use case.

This should be much less susceptible to forgetting to handle the ZEND_OBSERVER_ENABLED temporary explicitly.

@dstogov dstogov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should work.

@scottbuscemi

Copy link
Copy Markdown

What's the process for having this merged in?

@dstogov

dstogov commented Jul 22, 2024

Copy link
Copy Markdown
Member

@bwoebi are you going to merge this?

@bwoebi bwoebi closed this in a18df90 Jul 22, 2024
@bwoebi

bwoebi commented Jul 22, 2024

Copy link
Copy Markdown
Member Author

Yes, sorry, forgot about this PR :-)

@scottbuscemi

Copy link
Copy Markdown

Curious - will this also be merged into the 8.3 branch, or is that one unaffected?

@bwoebi

bwoebi commented Jul 29, 2024

Copy link
Copy Markdown
Member Author

@scottbuscemi The fix landed in PHP 8.2 and 8.3 as well. Don't ask me why github doesn't display the PHP-8.2 and PHP-8.3 branches on the commit though...

@dsmith4-godaddy

Copy link
Copy Markdown

The change logs don't reflect this fix having made it into either 8.2.22 or 8.3.10 (which were release a couple days after the above). Is this because this PR was too close to the release date, and they're going to be published in the next versions?

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