[php-src] Issue #8079: Recent patch to SplFixedArray causes array_walk + json encode to hang
| From: | TysonAndre | Date: | Fri, 11 Feb 2022 14:18:13 +0000 |
| Subject: | [php-src] Issue #8079: Recent patch to SplFixedArray causes array_walk + json encode to hang | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-239673@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/8079
Comment Author: TysonAndre
As another example of Z_OBJPROP_P being assumed to return the same pointer every time in
json_encode:
The following example also has a stack overflow in the latest commit, repeatedly outputting
In
jsonSerialize. Debug statements indicate the hash table is repeatedly duplicated and
spl_fixedarray_object_get_properties is repeatedly called.
```php
<?php
class VarDumper implements JsonSerializable {
public function __construct(private $parent) {
}
public function jsonSerialize() {
echo "In jsonSerialize\n";
var_dump($this->parent);
return ['mutated'];
}
}
call_user_func(function () {
$x = new SplFixedArray(3);
$x[0] = new VarDumper($x);
$x[1] = $x;
$x[2] = new stdClass();
echo json_encode($x, JSON_PARTIAL_OUTPUT_ON_ERROR);
});
```