[php-src] Issue #20503: Assertion failure in _zend_hash_str_add_or_update_i triggered by invalid array/dynamic property manipulation during JSON
encoding
| From: | vi3tL0u1s | Date: | Sun, 16 Nov 2025 09:31:35 +0000 |
| Subject: | [php-src] Issue #20503: Assertion failure in _zend_hash_str_add_or_update_i triggered by invalid array/dynamic property manipulation during JSON encoding |
||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251233@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20503
Author: vi3tL0u1s
### Description
The following code:
```php
<?
for ($i = 0; $i <= 2; $j++) {
$a[] = $$x[ ! 0] = $obj = new DateInterval('P1W');
$a = false;
$aniay['abc'] = $obj->prop3 = $y = (array) $a[] =& $ $u;
$$x[$key]-= $aniay['abc'] = $a === $ao = new ArrayObject();
var_dump(json_decode(json_encode($a), '1000001'));
}
```
Resulted in this output:
```
php: /path/to/php-src/Zend/zend_hash.c:912: _zend_hash_str_add_or_update_i: Assertion
`(zend_gc_refcount(&(ht)->gc) == 1) || ((ht)->u.flags & (1<<6))' failed.
Aborted
```
Commit:
```
035f95cf5e016236cca11bc293dc04d40b40e45c
```
Build configuration:
```
CC="clang" CXX="clang++" CFLAGS="-fsanitize=address -g -O0"
CXXFLAGS="-fsanitize=address -g -O0" LDFLAGS="-fsanitize=address" ./buildconf
--force && ./configure --enable-debug --enable-address-sanitizer --disable-shared --with-pic
--enable-mbstring --with-zlib
```
### PHP Version
```plain
PHP 8.6.0-dev (cli) (built: Nov 16 2025 19:51:33) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies
```
### Operating System
Ubuntu 22.04