[php-src] Issue #20881: Hang in Windows after upgrade 8.4.6 to 8.4.7, unpacking IteratorAggregate with custom Traversable when unpacking
| From: | dynasource | Date: | Fri, 09 Jan 2026 08:52:48 +0000 |
| Subject: | [php-src] Issue #20881: Hang in Windows after upgrade 8.4.6 to 8.4.7, unpacking IteratorAggregate with custom Traversable when unpacking | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-251511@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/20881
Author: dynasource
### Description
The following code hangs in after testing out 8.5. Narrowed it down to an earlier version 8.4.7 in
which this behavior first occurs. In 8.4.6 is works with no issues. Seems only to apply in Windows.
In non-windows it seems to run fine: https://3v4l.org/eRYIJ#v8.4.7
```php
<?php
class ArrayMap implements \Iterator
{
public function __construct(private array $array)
{
}
public function current(): mixed
{
return current($this->array);
}
public function next(): void
{
next($this->array);
}
public function key(): int|string|null
{
return key($this->array);
}
public function valid(): bool
{
return key($this->array) !== null;
}
public function rewind(): void
{
reset($this->array);
}
}
class Aggregate implements \IteratorAggregate
{
public function __construct(private array $array)
{
}
public function getIterator(): Traversable
{
return new ArrayMap($this->array);
}
}
class Y
{
}
class Z
{
}
$_1 = new Aggregate([Z::class => Z::class,]);
var_dump(1);
$_2 = [...iterator_to_array($_1, true)];
var_dump(2);
$_3 = [...$_2, Y::class => Z::class];
var_dump(3);
$_4 = new Aggregate($_3);
var_dump(4);
[...$_4];
var_dump(5);
```
Resulted in this output:
```
int(1)
int(2)
int(3)
int(4)
it hangs here with max cpu
```
But I expected this output instead:
```
int(1)
int(2)
int(3)
int(4)
int(5)
```
### PHP Version
```plain
PHP 8.4.7 (cli) (built: May 6 2025 14:14:22) (NTS Visual C++ 2022 x64)
Copyright (c) The PHP Group
Zend Engine v4.4.7, Copyright (c) Zend Technologies
```
### Operating System
Windows