-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-14873: PHP 8.4 min function fails on typed integer #14903
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
The problem is that this line in the VM: `ZVAL_NULL(result);` changes the type of arg1 as well, because after the DFA pass the result and input both use CV0($result). We should not contract assignments with CVs in frameless calls with arguments. An older attempt is found at phpGH-14876 that tried to modify the VM/JIT.
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.
Thank you for having a look!
Zend/Optimizer/dfa_pass.c
Outdated
@@ -325,6 +325,11 @@ static bool opline_supports_assign_contraction( | |||
return 0; | |||
} | |||
|
|||
if (opline->opcode >= ZEND_FRAMELESS_ICALL_1 && opline->opcode <= ZEND_FRAMELESS_ICALL_3) { | |||
/* Frameless calls override the return value, but the return value may overlap with the arguments. */ | |||
return opline->op1_type != IS_CV || opline->op1.var != cv_var; |
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.
Can the exact same issue not arise with op2? I.e.
CV0($value) = FRAMELESS_ICALL_2(min) int(100) CV0($value)
Clearing result would clear op2.
Same with OP_DATA for ZEND_FRAMELESS_ICALL_3.
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.
Yes indeed, I don't know why I missed this sorry
cefb129
to
0cf179e
Compare
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.
Thanks @nielsdos!
The problem is that this line in the VM:
ZVAL_NULL(result);
changes the type of arg1 as well, because after the DFA pass the result and input both use CV0($result).We should not contract assignments with CVs in frameless calls with arguments.
An older attempt is found at GH-14876 that tried to modify the VM/JIT.