Repository navigation
Cherry pick #110263 to 25.8: Fix heap-buffer-overflow when serializing a shared quantileTDigest state - #110472
Merged
robot-ch-test-poll2 merged 7 commits intoJul 15, 2026
Conversation
QuantileTDigest::serialize() called compress(), which sorts the centroids buffer in place, so serialize() mutated the aggregate state. But IAggregateFunction::serialize takes a ConstAggregateDataPtr, and the same state can be shared between rows (a replicated / const aggregate-state column used as a GROUP BY key shares one state pointer across rows). When such a column is a parallel GROUP BY key, several pipeline threads serialize the same state concurrently, racing inside compress()/RadixSort and writing one element past the centroids buffer (ASAN heap-buffer-overflow in RadixSort::radixSortLSDInternal). serialize() is now const and never touches the shared buffer: if the digest is already compacted it writes as is, otherwise it compresses a local copy. The const_cast in AggregateFunctionQuantile::serialize is dropped. Co-Authored-By: Claude Opus 4.8 <[email protected]>
The flaky check reruns changed tests ~50x and FAILs any single run over 180s (TEST_MAX_RUN_TIME_IN_SECONDS) unless the test carries the long tag. The 30-iteration x 200k-row re-aggregation loop blew past that on the slower sanitizer builds (msan/debug/tsan): 'Test runs too long (> 180s)' plus hard-timeout process-group kills. Add the long tag (exempts the 180s flaky-check FAIL and cuts the rerun count to ~10%) and shorten the loop to 10 iterations. The pre-fix binary trips the heap-buffer-overflow within the first 1-2 iterations under ASan, so 10 iterations keeps the failure reliable with 5x margin while each run finishes in a few seconds. Co-Authored-By: Claude Opus 4.8 <[email protected]>
SequenceNextNodeImpl::serialize took a ConstAggregateDataPtr, const_cast-ed it and sorted the value buffer in place. A shared/const sequenceNextNodeState column (replicated or used as a parallel GROUP BY key) is then reordered concurrently by several pipeline threads, which is a data race and can yield wrong results, the same class of bug fixed for quantileTDigest in this PR. Sort a local copy of the node pointers instead. Serialization stays byte-identical (values are always written in sorted order). Co-Authored-By: Claude Opus 4.8 <[email protected]>
Style check forbids raw std::vector in server code. Use the memory-tracked drop-in for the local sorted node-pointer copy. Co-Authored-By: Claude Opus 4.8 <[email protected]>
…t-serialize-shared-state Fix heap-buffer-overflow when serializing a shared quantileTDigest state
…ypick/25.8/110263 # Conflicts: # src/AggregateFunctions/AggregateFunctionSequenceNextNode.cpp
Member
|
Resolved the conflict with |
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.
Original pull-request #110263
Do not merge this PR manually
This pull-request is a first step of an automated backporting.
It contains changes similar to calling
git cherry-picklocally.If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.
The check results does not matter at this step - you can safely ignore them.
Troubleshooting
If the conflicts were resolved in a wrong way
If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:
pr-cherrypicklabel from the PRYou also need to check the Original pull-request for
pr-backports-createdlabel, and delete if it's presented thereThe PR source
The PR is created in the CI job