Skip to content

Fix SIGILL in the SimSIMD CPU probe on AArch64 cores without PAuth - #131762

Closed
lazerg wants to merge 1 commit into
ClickHouse:masterfrom
lazerg:fix/issue-131748-simsimd-retaa
Closed

lazerg wants to merge 1 commit into
ClickHouse:masterfrom
lazerg:fix/issue-131748-simsimd-retaa

Conversation

@lazerg

@lazerg lazerg commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Closes: #131748
Related: #119685

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

...

With -mbranch-protection=pac-ret, clang turns autiasp; ret into retaa in functions built for ARMv8.3 or newer. SimSIMD's CPU probe _simsimd_capabilities_arm is built under target("arch=armv8.5-a+sve"), so it ends in retaa and gets SIGILL on cores without FEAT_PAuth (Graviton2, Ampere Altra) the first time a vector_similarity index is built or a *Transposed distance function runs. This builds _simsimd with -mbranch-protection=none.

I checked it with the current master aarch64 build under qemu-aarch64 -cpu neoverse-n1: the INSERT from the issue and L2DistanceTransposed both die with SIGILL at _simsimd_capabilities_arm. Those 6 SimSIMD functions are the only places with retaa in the binary. When I build c/lib.c with the same flags plus this one, no retaa is left, and the probe returns on both N1 and V1.


Workflow [PR]
Sync PR [sync-upstream/pr/131762]

@clickhouse-gh clickhouse-gh Bot added the comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. label Nov 15, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 15, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Nov 15, 2026
@clickhouse-gh

clickhouse-gh Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [be9df66]

Summary: ❌

job_name test_name status info comment
Build (arm_release) FAIL
Build ClickHouse FAIL cidb
python3 ./ci/jobs/scripts/job_hooks/build_profile_hook.py FAIL
Performance Comparison (amd_release, master_head, 3/6) ERROR
Performance Comparison (amd_release, master_head, 4/6) ERROR
Performance Comparison (amd_release, master_head, 6/6) ERROR
Docker server image DROPPED
Docker keeper image DROPPED
Install packages (arm_release, deb) DROPPED
Install packages (arm_release, rpm) DROPPED
Install packages (arm_release, tgz) DROPPED
Compatibility check (arm_release) DROPPED

AI Review

Summary

PR #131762, reviewed at be9df663c5cc88081cf557422b1eb12c9a15722c, disables return-address signing for the AArch64 _simsimd target to prevent the CPU probe from executing unsupported retaa instructions on cores without FEAT_PAuth. The target-private override covers the shared implementation used by both vector_similarity indexes and transposed distance functions. The loss of signing within this library is explicit. No actionable findings.

Missing context / blind spots
  • ⚠️ I could not independently repeat the compiler or runtime checks: this checkout has no Clang installation, configured build, or populated SimSIMD submodule. The PR supplies focused evidence: the original queries fail under Neoverse N1 emulation, while recompiling with the override removes retaa and the probe returns on N1 and V1. A run of both queries against the final patched binary under N1 emulation would close the remaining end-to-end verification gap.
  • ⚠️ The main build and test jobs were still pending or running at review time; their final results remain to be checked in the Praktika report.
Final Verdict

Status: ✅ Approve. No code changes requested; the source trace and reported compiler/probe checks support this narrowly scoped fix.

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR. labels Nov 15, 2026
alexey-milovidov added a commit that referenced this pull request Nov 15, 2026
#119685 was reverted in #131765 because the `arm_release` binary died with
SIGILL on cores without `FEAT_PAuth` (Graviton2, Ampere Altra) on the first
SimSIMD call: SimSIMD compiles its CPU probe `_simsimd_capabilities_arm` and
five bf16 NEON kernels for ARMv8.3+, where clang folds `autiasp; ret` into
`retaa`, which is not in the `NOP` space.

Build `_simsimd` with `-mbranch-protection=none` (the same fix as #131762).
Compiled with the `arm_release` flags, `c/lib.c` goes from 7 `retaa` to 0.

Add a check to the `arm_release` compatibility check that scans the code
sections of the packaged binary for `retaa` and `retab` and names the
functions through `system.symbols`. A test run on Graviton3 would never notice
the next such case. On the `arm_release` package of #131745 (pac-ret on) it
reports exactly the 6 SimSIMD functions; on that of d88a8f1 (the master
commit before #119685) it passes.

Closes: #131748
Related: #131762
Related: #131765

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov added a commit that referenced this pull request Nov 15, 2026
Building all of `_simsimd` with `-mbranch-protection=none` broke the
`arm_release` link: a callee whose branch protection differs from the
caller's is not inlined, so ThinLTO stopped inlining `simsimd_bf16_to_f32`
from `c/lib.c` into the `vectorize(enable)` loops of usearch, and
`-Wpass-failed` turned "loop not vectorized" into a link error (also in
#131762). Reproduced with a two-file ThinLTO example on clang 21.

Revert that and bump `contrib/SimSIMD` to ClickHouse/SimSIMD@7cd5fbe8bb08
(branch `pac-ret-no-retaa`, on top of the previous pin e81e1c2de244), which
adds `branch-protection=none` to the ARMv8.3+ targets only: the CPU probe
(`arch=armv8.5-a+sve`) and the bf16 kernels (`arch=armv8.6-a+...`).
Compiled with the `arm_release` flags plus `pac-ret`, `c/lib.c` has 0
`retaa` (7 before) and 102 signed functions (109 before).

CI report: https://github.com/ClickHouse/ClickHouse/actions/runs/43723362796/job/132846622615

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added the external Author is not a member of the ClickHouse organization label Nov 16, 2026
@Algunenano

Copy link
Copy Markdown
Member

Superseeded by #131784 and also a step in the wrong direction

@Algunenano Algunenano closed this Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-external-dependencies Third-party deps updates in contrib/, vendored code, and platform base libraries. external Author is not a member of the ClickHouse organization pr-not-for-changelog This PR should not be mentioned in the changelog submodule changed At least one submodule changed in this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIGILL on AArch64 cores without PAuth: SimSIMD CPU probe returns via retaa

3 participants