-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Conversation
Zend/Optimizer/zend_optimizer.c
Outdated
op_array->T += ZEND_OBSERVER_ENABLED; // reserve last temporary for observers if enabled | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 :-)
There was a problem hiding this 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work.
What's the process for having this merged in? |
@bwoebi are you going to merge this? |
Yes, sorry, forgot about this PR :-) |
Curious - will this also be merged into the 8.3 branch, or is that one unaffected? |
@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... |
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? |
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.