Uh oh!
There was an error while loading. Please reload this page.
Reapply GH-17712 with a fix for internal class constants - #18464
Conversation
DanielEScherzer
commented
Apr 29, 2025
@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? |
iluuu1994
left a comment
There was a problem hiding this comment.
I believe this should work. Thank you!
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
f8c772e to
5c6d750CompareDanielEScherzer
commented
Apr 29, 2025
<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 |
SakiTakamachi
left a comment
There was a problem hiding this comment.
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 |
iluuu1994
commented
Apr 30, 2025
Obviously, we'll need to check why this segfaults. 🙂 |
DanielEScherzer
commented
Apr 30, 2025
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. |
DanielEScherzer
commented
Apr 30, 2025
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) |
iluuu1994
commented
Apr 30, 2025
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 |
remicollet
commented
Apr 30, 2025
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 ? |
iluuu1994
commented
Apr 30, 2025
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 |
DanielEScherzer
commented
Apr 30, 2025
Where would we check |
iluuu1994
commented
Apr 30, 2025
@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. |
0a6f5a7 to
615b9ffCompareDanielEScherzer
commented
Apr 30, 2025
Okay, added around the call site - new patch reapplies yours with my fixes |
SakiTakamachi
commented
May 1, 2025
done! |
615b9ff to
12661eaCompareDanielEScherzer
commented
May 3, 2025
<rebased, should be ready for review for 8.4.8> |
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. FixesphpGH-18463FixesphpGH-17711
12661ea to
6260e33CompareDanielEScherzer
commented
May 25, 2025
Missed out on 8.4.8 but I'll merge this as soon as CI passes |
DanielEScherzer
commented
May 25, 2025
ndossche
commented
May 26, 2025
It's right |
iluuu1994
commented
May 26, 2025
Master is failing, though. |
DanielEScherzer
commented
May 26, 2025
|
This led to recursion being added to but not removed from internal constants.
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.FixesGH-18463
FixesGH-17711