Skip to content

Fix GH-25415: Segfault in FilterIterator::next() after failed parent ctor - #25417

Open
lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25415
Open

lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-25415

Conversation

@lazerg

@lazerg lazerg commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

When a closed generator is passed to parent::__construct() of a dual iterator, the constructor throws after the object is already marked as constructed, so inner.iterator stays NULL. If the subclass catches the exception, spl_dual_it_next() only checked for a NULL inner iterator when do_free was 0, so next() on FilterIterator, IteratorIterator, LimitIterator and friends dereferenced it. NoRewindIterator had the same problem in valid(), key(), current() and next().

The NULL check in spl_dual_it_next() now runs in both cases, and the NoRewindIterator methods behave like the other iterators here: valid() returns false, key() and current() return NULL, and next() throws the existing "inner constructor wasn't initialized" error.

Fixes #25415

@lazerg

lazerg commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

The LINUX_X32_DEBUG_ZTS Tracing JIT failure also happens on PHP-8.4 itself (runs 43196288502 and 43186660061), so it isn't caused by this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant