Skip to content

Cache each dispatched kernel with its exact type - #30

Merged
Algunenano merged 1 commit into
ClickHouse/v6.5.15from
cfi-typed-kernel-dispatch
Nov 10, 2026
Merged

Algunenano merged 1 commit into
ClickHouse/v6.5.15from
cfi-typed-kernel-dispatch

Conversation

@Algunenano

Copy link
Copy Markdown
Member

🤖 The dynamic dispatchers in c/lib.c stored the kernel they find in a punned function pointer type, such as simsimd_metric_dense_punned_t, which takes void const *, and called it through that type, while the kernels take pointers to their own scalar type. Calling a function through a pointer of another type is undefined behavior, and Clang CFI (-fsanitize=cfi-icall) rejects such calls.

This types the cached pointer as __typeof__ of the dispatcher itself, which has exactly the signature of the kernels it dispatches to. No behavior change otherwise.

The dynamic dispatchers in `c/lib.c` stored the kernel they find in a punned function pointer
type, such as `simsimd_metric_dense_punned_t`, which takes `void const *`, and called it
through that type, while the kernels take pointers to their own scalar type. Calling a
function through a pointer of another type is undefined behavior, and Clang CFI
(`-fsanitize=cfi-icall`) rejects such calls.

Type the cached pointer as `__typeof__` of the dispatcher itself, which has exactly the
signature of the kernels it dispatches to.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Algunenano
Algunenano merged commit 998cb27 into ClickHouse/v6.5.15 Nov 10, 2026
alexey-milovidov pushed a commit to groeneai/ClickHouse that referenced this pull request Nov 17, 2026
…h protection

Bumps `contrib/SimSIMD` to the merge of ClickHouse/SimSIMD#33. The CPU
probe `_simsimd_capabilities_arm` reads `ID_AA64ZFR0_EL1` by its encoding instead of being
compiled for `arch=armv8.5-a+sve`, and the bf16 kernels use `+simd+bf16` / `+sve+sve2+bf16`
instead of `arch=armv8.6-a+...`. Nothing in `SimSIMD` is compiled for ARMv8.3 or later anymore,
so it no longer needs `branch-protection=none` and all of its functions are signed under
`-mbranch-protection=pac-ret`, without `retaa` that would raise SIGILL on cores without
`FEAT_PAuth`.

The bump also brings ClickHouse/SimSIMD#30 (typed kernel dispatch).

Related: ClickHouse/SimSIMD#33
Related: ClickHouse#131748
Related: ClickHouse#131784

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant