Skip to content

Cherry pick #95072 to 25.12: Fix crash in getTopKMarks when limit is zero#95086

Merged
robot-clickhouse-ci-2 merged 2 commits intobackport/25.12/95072from
cherrypick/25.12/95072
Jan 25, 2026
Merged

Cherry pick #95072 to 25.12: Fix crash in getTopKMarks when limit is zero#95086
robot-clickhouse-ci-2 merged 2 commits intobackport/25.12/95072from
cherrypick/25.12/95072

Conversation

@robot-clickhouse-ci-2
Copy link
Copy Markdown
Contributor

Original pull-request #95072

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-pick locally.
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:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 2 commits January 25, 2026 13:47
When `LIMIT -0.` (or any expression that evaluates to 0) is used with
`use_skip_indexes_for_top_k = 1`, the `getTopKMarks` functions would
call `queue.top()` on an empty priority queue, causing undefined
behavior and a segmentation fault.

The fix adds an early return when `n == 0` in both `getTopKMarks`
overloads, since requesting the top 0 elements should return nothing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Fix crash in `getTopKMarks` when limit is zero
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-critical-bugfix labels Jan 25, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 merged commit 577a386 into backport/25.12/95072 Jan 25, 2026
99 of 101 checks passed
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 deleted the cherrypick/25.12/95072 branch January 25, 2026 17:12
@clickhouse-gh clickhouse-gh bot added the ready-for-backport PR is eligible for backporting (merged 7+ days ago, not reverted) label Mar 27, 2026
@maxknv maxknv removed the ready-for-backport PR is eligible for backporting (merged 7+ days ago, not reverted) label Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants