Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

nielsdos
Copy link
Member

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.

@nielsdos nielsdos linked an issue Jul 10, 2024 that may be closed by this pull request
@nielsdos nielsdos marked this pull request as ready for review July 10, 2024 13:18
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.
Copy link
Member

@iluuu1994 iluuu1994 left a 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!

@@ -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;
Copy link
Member

@iluuu1994 iluuu1994 Jul 10, 2024

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.

Copy link
Member Author

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

@nielsdos nielsdos force-pushed the fix-14873-2 branch 2 times, most recently from cefb129 to 0cf179e Compare July 10, 2024 18:10
@nielsdos nielsdos requested a review from iluuu1994 July 10, 2024 19:10
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @nielsdos!

@nielsdos nielsdos closed this in 1a07bb9 Jul 12, 2024
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.

PHP 8.4 min function fails on typed integer
2 participants