Repository navigation
Conversation
WITH x ORDER BY x + x SKIP 0 RETURN x + x AS y crashed intermittently with heap corruption. A projection keeps out-of-scope expressions in their groups, so the ORDER BY key x + x, dropped by the WITH, stayed registered under its unique name. The RETURN's x + x has the same name, and FactorizationGroup::insertExpression kept the old name-to-position entry, so the projection installed its result vector in the slot the ORDER BY scan still wrote through: a use after free. The group now maps the name to the new expression's position. Literals get a unique name per binding, so x + 1 in both places was never affected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
This work was produced with the help of language models.
Fixes #1282.
UNWIND [10, 20, NULL, 5] AS x WITH x ORDER BY x + x SKIP 0 RETURN x + x AS ycrashed the process intermittently with a SIGSEGV or a glibccorrupted double-linked listabort; under ASan it is a use after free in the ORDER BY scan on the first execution.Fix. A projection keeps out-of-scope expressions in their groups, so the ORDER BY key the
WITHdropped was still registered when theRETURN'sx + x, same unique name, was inserted again, andFactorizationGroup::insertExpressionkept the old name-to-position entry: the final projection's result vector took the ORDER BY scan's slot, freeing the one the scan writes through. The group now maps the name to the new expression's position. The old one stays in the group's list, so its vector is still allocated, and the scan, whose positions come from the ORDER BY operator's own schema, keeps writing there. The removedDASSERTtreated such a leftover as impossible; inserting a name that is still in scope remains asserted inSchema::insertToGroupAndScope.Tests.
order_by/order_by_key_repeated.testProjectionRepeatsDiscardedOrderByKeyruns the query and itsx * xvariant 2000 times each with-CHECK_ORDER; onmainit aborts withcorrupted double-linked listpartway through the loop and passes here. Full suite: no failures.