Skip to content

Cherry pick #99539 to 26.3: Fix segfault in UBSan build when calling JIT-compiled sort description - #102810

Merged
robot-clickhouse-ci-1 merged 5 commits into
backport/26.3/99539from
cherrypick/26.3/99539
Apr 15, 2026
Merged

robot-clickhouse-ci-1 merged 5 commits into
backport/26.3/99539from
cherrypick/26.3/99539

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Original pull-request #99539

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 5 commits March 16, 2026 05:28
UBSan's `-fsanitize=function` reads a type signature at
`function_pointer - 8` before every indirect call. JIT-compiled
functions lack this prologue, and when the JIT code sits at a page
boundary, the pre-call read hits unmapped memory, causing a SIGSEGV.

The `callJITFunction` wrapper (with `NO_SANITIZE_UNDEFINED`) already
exists and is used for all other JIT function calls, but the two call
sites in `SortCursor::greaterAt` and `SimpleSortCursor::greaterAt`
were missing it.

Also change `callJITFunction` to return `decltype(auto)` instead of
`void` so it can be used with non-void JIT functions like
`JITSortDescriptionFunc` (returns `int8_t`).

https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=96130&sha=041d2e94874b0ca8cc527e2edec4f3e5daf012ee&name_0=PR&name_1=Stateless%20tests%20%28amd_ubsan%2C%20parallel%29

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
The `callJITFunction` with `decltype(auto)` return now propagates the
`int8_t` return type of `JITSortDescriptionFunc`, which clang-tidy flags
as `bugprone-signed-char-misuse` when assigned to `int`. Add NOLINT
comments since the sign is meaningful here (comparator returns -1/0/1).

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Fix segfault in UBSan build when calling JIT-compiled sort description
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 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 labels Apr 15, 2026
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 merged commit 967e9ce into backport/26.3/99539 Apr 15, 2026
274 of 285 checks passed
@robot-clickhouse-ci-1
robot-clickhouse-ci-1 deleted the cherrypick/26.3/99539 branch April 15, 2026 12:37
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!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants