Hang in Windows after upgrade 8.4.6 to 8.4.7, unpacking IteratorAggregate with custom Traversable when unpacking
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.2k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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
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
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo il riproduttore fornito su Windows con PHP 8.4.7 e confrontalo con 8.4.6, concentrandoti su iterator_to_array() e sull’unpacking degli array di IteratorAggregate. Il lavoro è completato quando l’unpacking finale termina senza bloccarsi e stampa int(5), preservando il comportamento segnalato sui sistemi non-Windows.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- backend, operating-systems
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100