[php-src] Issue #25228: Segfault in IteratorIterator::__construct() when `$class` is an abstract IteratorAggregate

From: Date: Thu, 05 Nov 2026 23:32:33 +0000
Subject: [php-src] Issue #25228: Segfault in IteratorIterator::__construct() when `$class` is an abstract IteratorAggregate
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-254030@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/25228 Author: edsrzf ### Description The following code: ```php <?php abstract class A implements IteratorAggregate {} class B extends A { function getIterator(): Iterator { return new ArrayIterator([1]); } } new IteratorIterator(new B, 'A'); ``` Resulted in this output: ``` [1] 44141 segmentation fault php test.php ``` But I expected an Error (such as "Cannot call abstract method IteratorAggregate::getIterator()") or for B::getIterator() to be called, not a segfault. ## Analysis The crash appears to come from spl_get_iterator_from_aggregate() in ext/spl/spl_iterators.c. It calls ce->iterator_funcs_ptr->zf_new_iterator directly, and for an abstract class that's the interface's abstract getIterator(), which has no body. Calling it directly skips the "Cannot call abstract method" check. ### PHP Version ```plain PHP 8.5.12 (cli) (built: Oct 19 2026 17:02:46) (NTS) Copyright (c) The PHP Group Built by Homebrew Zend Engine v4.5.12, Copyright (c) Zend Technologies with Zend OPcache v8.5.12, Copyright (c), by Zend Technologies ``` ### Operating System MacOS 25.6.0

« previous php.bugs (#254030) next »