Skip to content

Cherry pick #126120 to 26.7: Fix out-of-bounds accesses in the replxx line editor - #126616

Merged
PedroTadim merged 7 commits into
backport/26.7/126120from
cherrypick/26.7/126120
Oct 19, 2026
Merged

PedroTadim merged 7 commits into
backport/26.7/126120from
cherrypick/26.7/126120

Conversation

@robot-clickhouse-ci-2

Copy link
Copy Markdown
Contributor

Original pull-request #126120

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.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

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

groeneai and others added 7 commits October 15, 2026 19:54
Update `replxx` with four fixes:

- An incremental history search (Ctrl-S, Ctrl-T, Meta-R, and Ctrl-R in the
  web terminal and SSH sessions) that started on a recalled and then edited
  history line mapped the cursor of the edited line onto the old text of the
  entry, so a search that found nothing left the cursor past the end of the
  line. The next edit wrote out of bounds and aborted
  `clickhouse-client`/`clickhouse-local`; through the web terminal or an SSH
  PTY session, which run the editor inside the server, it aborted the server.
- Ctrl-W and Meta-. passed `char32_t` code points to `isspace`, which is
  undefined for values above 255 and crashed on e.g. U+10FFFF.
- A tab renders as 4 spaces, but the prompt was rendered in place, so a search
  prompt with a tab (Meta-R on a line with a tab) overflowed its buffer.
- The prompt's last line position was the number of characters minus the
  cursor column, which is negative for a prompt with a double-width character
  (e.g. in the server's `display_name`), so leaving a history search read
  before the prompt text and aborted.

The commits are on top of the current pointer, as the broader `replxx` update
goes into a separate PR.

Closes #126008

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse/replxx#50 is merged into `master` of `replxx`, and the copy of
the same fixes on top of the previous pointer (ClickHouse/replxx#51) is
closed. Point the submodule to the merge commit.

This also brings the `master` changes that were not in the previous
pointer: editing modes, `Esc` delay, prompt indentation, per-terminal
state and the Meta+Up fix (ClickHouse/replxx#36, #43, #44, #45, #46, #47,
#48). `04909_client_hints_history_navigation`, which the `Esc` delay
broke before #48, passes 10/10 locally.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Moving `contrib/replxx` to `replxx` master brought in a regression from the
`Esc` delay support: `read_unicode_character` called `read` only when `poll`
reported `POLLIN`, so on `POLLHUP`, `POLLERR`, or `POLLNVAL` alone the
uninitialized character was decoded as input. The pointer now goes to the
merge of `replxx` master into the branch of ClickHouse/replxx#49, which calls
`read` on any event (end of input or error ends the input, as before), and
also re-reads the terminal width on refresh for embedded clients that do not
receive `SIGWINCH`.

Addresses review: #126120 (comment)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ClickHouse/replxx#49 is merged into `master` of `replxx`. Point the
submodule to the merge commit; its tree is the same as the head of the
#49 branch used before, so the code does not change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rsor

Fix out-of-bounds accesses in the replxx line editor
@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-bugfix Pull request with bugfix, not backported by default labels Oct 18, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

The only conflict is the contrib/replxx pointer: 26.7 has its own replxx commit 7bca154 (from #125868), so the move to replxx master does not apply. As in #125868, I cherry-picked the four fixes of ClickHouse/replxx#50 onto that commit instead. They apply cleanly, and the change is byte-identical to ClickHouse/replxx#51.

The replxx commit is only in my fork, so this needs two pushes, replxx first:

git fetch https://github.com/groeneai/replxx clickhouse/26.7-fix-history-search-cursor && git push https://github.com/ClickHouse/replxx FETCH_HEAD:refs/heads/clickhouse/26.7-fix-history-search-cursor
git fetch https://github.com/groeneai/ClickHouse resolve-26.7-cherrypick-126120 && git push origin FETCH_HEAD:cherrypick/26.7/126120
  • 24b21a1bd25d is a fast-forward from the cherry-pick head 46e93176e28f. Compared with backport/26.7/126120 it changes only contrib/replxx (7bca154 -> 0e8815c) and adds 05401_client_history_search_crash unchanged from master.
  • On a 26.7 build (clang-21, Debug) the test passes 50/50 with 0e8815c and aborts 3/3 with 7bca154 (Hardening assertion ... is not a valid range after Ctrl-F). The official 26.7.22.4 image also aborts, on Ctrl-T, x, Ctrl-G with a double-width prompt.

@PedroTadim
PedroTadim merged commit 633f5f4 into backport/26.7/126120 Oct 19, 2026
13 checks passed
@PedroTadim
PedroTadim deleted the cherrypick/26.7/126120 branch October 19, 2026 14:17
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-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants