[php-src] PR #23197: Fix stack overflow in count() with COUNT_RECURSIVE and deep arrays

From: Date: Mon, 10 Aug 2026 10:29:55 +0000
Subject: [php-src] PR #23197: Fix stack overflow in count() with COUNT_RECURSIVE and deep arrays
Groups: php.git-pulls 
Request: Send a blank email to git-pulls+get-37725@lists.php.net to get a copy of this message
Pull Request: https://github.com/php/php-src/pull/23197 Author: lazerg php_count_recursive() recurses once per nesting level with no stack check, so count($array, COUNT_RECURSIVE) on a deeply nested array exhausts the native stack and the process dies with a segfault. This is the separate PR offered in #23125, applying the same stack limit check the neighbouring functions in ext/standard use, so the call throws an Error instead of crashing. There is no GitHub issue for it. The loop over the elements also breaks once the error is thrown, otherwise every remaining sibling recurses again and chains another Error onto the first one, and count() returns through RETURN_THROWS() in that case.

« previous php.git-pulls (#37725) next »