-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Reapply GH-17712 with a fix for internal class constants #18464
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
base: PHP-8.4
Are you sure you want to change the base?
Conversation
@php/release-managers-84 this fixes a regression from #17712 that is part of the not-yet-released PHP 8.4.7. Should this be included in 8.4.7 rather than waiting for 8.4.8? |
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 believe this should work. Thank you!
f8c772e
to
5c6d750
Compare
<adding the PHP 8.4 release managers as reviewers - if this should be included in 8.4.7 I'd rather one of you merge this, if it should wait until 8.4.8 let me know and I can merge it> |
So it seems that something is setting |
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.
We have decided to include this in version 8.4.7.
I plan to package RC2 with this change later today (Japan time), and will make an announcement once QA is complete.
If everything goes smoothly, I will release 8.4.7 as scheduled next week.
Okay, I'm working on a fix now for the class constants |
Obviously, we'll need to check why this segfaults. 🙂 |
Segfault is from the module number being 8 because of ZEND_ACC_DEPRECATED |
Ah sorry, I missed your earlier comment. I don't quite understand your explanation, and why that would cause a segfault now but not before. But it's way too late for me now, so I'll check tomorrow if you haven't already found the solution. |
The segfault now is from infinite recursion. Because ZEND_ACC_DEPRECATED is 1<<11, ZEND_CONSTANT_MODULE_NUMBER() returns 3 rather than PHP_USER_CONSTANT (0x7fffff) |
Ah ofc, makes sense. |
Okay, this is a bit trickier that that, because a class constant needs to be able to have the following flags
So basically class constants can't store the module number in the top 3 bytes if they want to support all of the things, and I'll adjust so that we have 16 bits for the flags (which is what I thought was already the case when I wrote https://php.github.io/php-src/core/data-structures/zend_constant.html). This limits the number of modules possible to 2^16 rather than 2^24, which should still be enough. I'll clean things up on master to be better documented |
Do we need to store the module id at all? I see this was not done previously for class constants, so can we not just check for The analogous fix for global constants can use |
Perhaps simpler to revert the problem (for 8.4.7RC2/8.4.7) and give more time for a proper fix in 8.4.8 ? |
I can revert GH-17712 and postpone until 8.4.8 if RMs prefer. Let me know if I should do that. Otherwise, I believe the |
Where would we check |
@DanielEScherzer Sadly, you can't add them to the macros but you'll have to add it around them at call-site. Regardless, I think it's better to revert GH-17712 for now so that we can tag. I'll do that in approx. half an hour. We can then re-apply with this fix. |
@SakiTakamachi Please cherry-pick 386ab1d for 8.4.7RC2. We'll reapply the patch for the 8.4 branch for 8.4.8 with the proper fix in the coming days. Edit: And please also d991215. |
Add recursion protection when emitting deprecation warnings for class constants, since the deprecation message can come from an attribute that is using the same constant for the message, or otherwise result in recursion. But, internal constants are persisted, and thus cannot have recursion protection. Otherwise, if a user error handler triggers bailout before the recursion flag is removed then a subsequent request (e.g. with `--repeat 2`) would start with that flag already applied. Internal constants can presumably be trusted not to use deprecation messages that come from recursive attributes. Fixes phpGH-18463 Fixes phpGH-17711
0a6f5a7
to
615b9ff
Compare
Okay, added around the call site - new patch reapplies yours with my fixes |
done! |
Add recursion protection when emitting deprecation warnings for class constants, since the deprecation message can come from an attribute that is using the same constant for the message, or otherwise result in recursion.
But, internal constants are persisted, and thus cannot have recursion protection. Otherwise, if a user error handler triggers bailout before the recursion flag is removed then a subsequent request (e.g. with
--repeat 2
) would start with that flag already applied. Internal constants can presumably be trusted not to use deprecation messages that come from recursive attributes.Fixes GH-18463
Fixes GH-17711