-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
JIT packed type guard crash #17577
Comments
devnexen
added
Extension: opcache
Category: JIT
Status: Verified
and removed
Status: Needs Triage
labels
Jan 26, 2025
Slightly simplified: <?php
$a = array(
array(1,2,3),
0,
);
function my_dump($var) {
}
foreach($a as $b) {
for ($i = 0; $i < 1; $i++) {
my_dump($b[$i]);
}
} Apparently, it
The problem is that a IS_ARRAY type check is missing when emitting the packed guard. |
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
Jan 26, 2025
When a guard check is created for a variable to check if it's a packed array, it is possible that there was no prior type check for that variable. This happens in the global scope for example when the variable aliases. In the test, this causes a dereference of address 8 because the integer element in `$a` is interpreted as an array address. This patch adds a type check if a prior one was not inserted, which should only be possible is NO_ALIAS is set (hence the assertion). In this case we also cannot set the stack type nor clear the MAY_BE_GUARD flag due to the aliasing.
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
Jan 26, 2025
When a guard check is created for a variable to check if it's a packed array, it is possible that there was no prior type check for that variable. This happens in the global scope for example when the variable aliases. In the test, this causes a dereference of address 8 because the integer element in `$a` is interpreted as an array address. This patch adds a type check if a prior one was not inserted. In the aliasing case we also cannot set the stack type nor clear the MAY_BE_GUARD flag.
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
Jan 26, 2025
When a guard check is created for a variable to check if it's a packed array, it is possible that there was no prior type check for that variable. This happens in the global scope for example when the variable aliases. In the test, this causes a dereference of address 8 because the integer element in `$a` is interpreted as an array address. This patch adds a type check if a prior one was not inserted.
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
Jan 26, 2025
When a guard check is created for a variable to check if it's a packed array, it is possible that there was no prior type check for that variable. This happens in the global scope for example when the variable aliases. In the test, this causes a dereference of address 8 because the integer element in `$a` is interpreted as an array address. This patch adds a check to see if the zval type is an array. If we were not able to determine or guard the type then we also cannot know the array is packed.
nielsdos
added a commit
to nielsdos/php-src
that referenced
this issue
Jan 26, 2025
When a guard check is created for a variable to check if it's a packed array, it is possible that there was no prior type check for that variable. This happens in the global scope for example when the variable aliases. In the test, this causes a dereference of address 8 because the integer element in `$a` is interpreted as an array address. This patch adds a check to see if the guard is handled. If we were not able to determine or guard the type then we also cannot know the array is packed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
The following code:
Resulted in this output:
To reproduce:
PHP Version
nightly
Operating System
No response
The text was updated successfully, but these errors were encountered: