[php-src] Issue #10200: zif_get_object_vars: Assertion `!(((__ht)->u.flags & (1<<2)) != 0)' failed.
Issue: https://github.com/php/php-src/issues/10200
Author: Deltik
### Description
The following code:
```php
<?php
function is_assoc($array)
{
if (!is_array($array) || array() === $array) return false;
return array_keys($array) !== range(0, count($array) - 1);
}
function bugRepro($xml)
{
$elements = get_object_vars($xml);
$elementNames = array_keys($elements);
if (is_assoc($elements)) {
foreach ($elementNames as $elementName) {
bugRepro($xml->{$elementName});
}
}
}
$xmlData = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<document>
<author name="Doesn't matter" />
<summary>Segmentation fault happens here</summary>
<description>Not reached</description>
<category>Not reached</category>
</document>
EOF;
$xml = simplexml_load_string($xmlData, 'SimpleXMLElement', LIBXML_NOCDATA);
bugRepro($xml);
print("OK" . PHP_EOL);
```
Resulted in this output:
```
php: /tmp/php-build/source/8.2.0/Zend/zend_builtin_functions.c:763: zif_get_object_vars: Assertion
`!(((__ht)->u.flags & (1<<2)) != 0)' failed.
Aborted
```
But I expected this output instead:
```
OK
```
This bug affects PHP 8.2.0 but not PHP 8.1.13.
PHP 8.2.0 was compiled with the following configure options:
```
--enable-sockets
--enable-exif
--with-zlib
--with-zlib-dir=/usr
--with-bz2
--enable-intl
--with-openssl
--enable-soap
--enable-xmlreader
--with-xsl
--enable-ftp
--enable-cgi
--with-curl=/usr
--with-tidy
--enable-sysvsem
--enable-sysvshm
--enable-shmop
--with-mysqli=mysqlnd
--with-pdo-mysql=mysqlnd
--with-pdo-sqlite
--enable-pcntl
--with-readline
--enable-mbstring
--enable-debug
--enable-fpm
--enable-bcmath
--enable-phpdbg
--with-webp
--enable-gd
--with-jpeg
--with-zip
--with-mhash
```
### PHP Version
PHP 8.2.0
### Operating System
Ubuntu 22.04
Thread (1 message)
- Deltik