fix(query): prevent cycles when analyzing hidden children#4659
Merged
WillLillis merged 1 commit intorelease-0.25from Jul 30, 2025
Merged
fix(query): prevent cycles when analyzing hidden children#4659WillLillis merged 1 commit intorelease-0.25from
WillLillis merged 1 commit intorelease-0.25from
Conversation
**Problem:** `query.c` compares the current analysis state with the previous analysis state to see if they are equal, so that it can return early if so. This prevents redundant work. However, the comparison function here differs from the one used for sorted insertion/lookup in that it does not check any state data other than the child index. This is problematic because it leads to infinite analysis when hidden nodes have cycles. **Solution:** Remove the custom comparison function, and apply the insertion/lookup comparison function in place of it. **NOTE:** This commit also changes the comparison function slightly, so that some comparisons are reordered. Namely, for performance, it returns early if the lhs depth is less than the rhs depth. Is this acceptable? Tests still pass and nothing hangs in my testing, but it still seems sketchy. Returning early if the lhs depth is greater than the rhs depth does seem to make query analysis hang, weirdly enough... Keeping the depth checks at the end of the loop also works, but it introduces a noticeable performance regression (for queries that otherwise wouldn't have had analysis cycles, of course). (cherry picked from commit 6850df9)
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.
Description
Backport of #4614 to
release-0.25.