Skip to content
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

SplFixedArray assertion failure with get_object_vars #17198

Closed
YuanchengJiang opened this issue Dec 17, 2024 · 3 comments
Closed

SplFixedArray assertion failure with get_object_vars #17198

YuanchengJiang opened this issue Dec 17, 2024 · 3 comments

Comments

@YuanchengJiang
Copy link

Description

The following code:

<?php
class MySplFixedArray extends SplFixedArray {
public $x;
}
class X {}
$array = new MySplFixedArray(2);
$array->{0} = new X();
try {get_object_vars($array);} catch (Exception $e) { echo($e); }

Resulted in this output:

php: /home/phpfuzz/WorkSpace/flowfusion/php-src/Zend/zend_hash.c:1163: zval *_zend_hash_index_add_or_update_i(HashTable *, zend_ulong, zval *, uint32_t): Assertion `(flag & (1<<3)) == 0' failed.
Aborted (core dumped)

PHP Version

nightly

Operating System

ubuntu 22.04

@nielsdos
Copy link
Member

Doesn't repro on 8.3, but it does on 8.4.

@nielsdos
Copy link
Member

Bisected to 780a828 (property hooks)

@nielsdos
Copy link
Member

Sigh: https://3v4l.org/rEdH1

@nielsdos nielsdos self-assigned this Dec 17, 2024
@nielsdos nielsdos changed the title Assertion failure Zend/zend_hash.c:1163 SplFixedArray assertion failure with get_object_vars Dec 17, 2024
nielsdos added a commit to nielsdos/php-src that referenced this issue Dec 17, 2024
Because the properties table contains both a numeric index and a string
index that map to 0 in a symbol table, this causes an assertion failure.
Looking at the manual page of get_object_vars(), it seems that only real
properties must be included. Given that SplFixedArray's elements are not
accessible like properties, they should be excluded. This restores PHP
8.3 behaviour. The reason that this didn't cause problems on 8.3 is
because it used a different handler (get_properties).
nielsdos added a commit that referenced this issue Dec 17, 2024
* PHP-8.4:
  Fix GH-17198: SplFixedArray assertion failure with get_object_vars
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants