Skip to content

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

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

Closed
wants to merge 2 commits into from

Conversation

bwoebi
Copy link
Member

@bwoebi bwoebi commented Apr 20, 2024

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 on lines 1241 to 1242
op_array->T += ZEND_OBSERVER_ENABLED; // reserve last temporary for observers if enabled

Copy link
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
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 :-)

Copy link
Member

@dstogov dstogov left a comment

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.
Copy link
Member

@dstogov dstogov left a comment

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

What's the process for having this merged in?

@dstogov
Copy link
Member

dstogov commented Jul 22, 2024

@bwoebi are you going to merge this?

@bwoebi bwoebi closed this in a18df90 Jul 22, 2024
@bwoebi
Copy link
Member Author

bwoebi commented Jul 22, 2024

Yes, sorry, forgot about this PR :-)

@scottbuscemi
Copy link

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

@bwoebi
Copy link
Member Author

bwoebi commented Jul 29, 2024

@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

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