Fix GH-23088: Stack overflow when comparing deeply nested arrays - #23090
Open
lazerg wants to merge 1 commit into
Open
Fix GH-23088: Stack overflow when comparing deeply nested arrays#23090lazerg wants to merge 1 commit into
lazerg wants to merge 1 commit into
Conversation
lazerg
force-pushed
the
fix/gh-23088-array-compare-stack-limit
branch
3 times, most recently
from
August 6, 2026 16:01
aa11ff5 to
983de1f
Compare
lazerg
force-pushed
the
fix/gh-23088-array-compare-stack-limit
branch
from
August 6, 2026 16:19
983de1f to
e0c17b3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Comparing two deeply nested arrays recurses through
zend_compare_arrays->zend_compare_symbol_tables->zend_hash_compareonce per nesting level, and nothing bounds that recursion.zend_hash_compare()only guards against cycles, so a non-cyclic array a few tens of thousands of levels deep runs the C stack out and the process dies with a segfault.===crashes the same way throughzend_is_identical().Both now check the stack limit before descending and throw an
Errorinstead, the same wayzend_std_compare_objects()already handles the object case.Fixes GH-23088