-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
zif_get_object_vars: Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed. #10200
Comments
I analyzed this issue for a bit. I can confirm this happens on 8.2 and higher. The issue occurs because the summary element does not have attributes in your example, so the array of properties is just
i.e. there is only an integer index here, so it's a packed hash table. But the code at that line 763 assumes it gets a non-packed hash table. Replacing Applying the following diff fixes this particular case, but there are probably more places where the following change needs to happen. diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 8813fa9788..5cebbbc560 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -760,7 +760,7 @@ ZEND_FUNCTION(get_object_vars)
} else {
array_init_size(return_value, zend_hash_num_elements(properties));
- ZEND_HASH_MAP_FOREACH_KEY_VAL(properties, num_key, key, value) {
+ ZEND_HASH_FOREACH_KEY_VAL(properties, num_key, key, value) {
bool is_dynamic = 1;
if (Z_TYPE_P(value) == IS_INDIRECT) {
value = Z_INDIRECT_P(value); |
I updated my repro snippet with a much simpler one. |
… error Casting a `SimpleXMLElement` to an array should be equivalent to `get_object_vars(…)` as far as I can tell. At least all existing tests pass and I don't see any visual regressions upon making this change. By replacing `get_object_vars(…)` with a cast to array, we sidestep this PHP 8.2.0 bug: php/php-src#10200 Fixes: e107inc#4938
… (1<<2)) != 0)' failed. This occurs because the array of properties is a single element with an integer key, not an associative array. Therefore it is a packed array and thus the assumption the iteration macro makes is invalid. This restores the behaviour of PHP<8.2.
Co-authored-by: Deltik <deltik@gmx.com>
…<<2)) != 0)' failed. This occurs because the array of properties is a single element with an integer key, not an associative array. Therefore it is a packed array and thus the assumption the iteration macro makes is invalid. This restores the behaviour of PHP<8.2. Closes GH-10209 Co-authored-by: Deltik <deltik@gmx.com> Signed-off-by: George Peter Banyard <girgias@php.net>
Casting a `SimpleXMLElement` to an array should be equivalent to `get_object_vars(…)` as far as I can tell. At least all existing tests pass and I don't see any visual regressions upon making this change. By replacing `get_object_vars(…)` with a cast to array, we sidestep this PHP 8.2.0 bug: php/php-src#10200 Fixes: e107inc/e107#4938
Closes GH-10252 Signed-off-by: George Peter Banyard <girgias@php.net>
* PHP-8.2: Move test for GH-10200 to the simplexml extension test directory
…perties This is a variant of phpGH-10200, but in a different place. Basically, simplexml may create a properties table that's packed instead of associative. But the macro that was used to loop over the properties table assumed that it was always associative. Replace it by the macro that figures it out automatically which one of the two it is.
…ties This is a variant of GH-10200, but in a different place. Basically, simplexml may create a properties table that's packed instead of associative. But the macro that was used to loop over the properties table assumed that it was always associative. Replace it by the macro that figures it out automatically which one of the two it is. For test: Co-authored-by: jnvsor Closes GH-10984.
Description
The following code:
Resulted in this output:
But I expected this output instead:
This bug affects PHP 8.2.0 but not PHP 8.1.13.
PHP 8.2.0 was compiled with the following configure options:
PHP Version
PHP 8.2.0
Operating System
Ubuntu 22.04
Additional Information
Here's the line in the PHP source code where the assertion error happens:
https://github.com/php/php-src/blob/PHP-8.2.0/Zend/zend_builtin_functions.c#L763
The text was updated successfully, but these errors were encountered: