Skip to content

Bump cpu_features to fix UBSan misaligned loads in IsVendor - #1127

Closed
dor-forer wants to merge 1 commit into
mainfrom
dor/cpu-features-ubsan-alignment
Closed

dor-forer wants to merge 1 commit into
mainfrom
dor/cpu-features-ubsan-alignment

Conversation

@dor-forer

@dor-forer dor-forer commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Describe the changes in the pull request

cpu_features v0.10.1 reads the CPUID vendor strings in IsVendor/SetVendor by casting const char* to uint32_t*. The strings are not 4-byte aligned, so an UBSan build stops in GetX86Info (reached from every *_GetDistFunc) with:

impl_x86__base_implementation.inl:248:18: runtime error: load of misaligned address ... for type 'const uint32_t', which requires 4 byte alignment

This blocks clean UBSan runs of anything that links VecSim. Upstream fixed it with memcpy in google/cpu_features#458. That fix is not in any release yet (v0.11.0 still has the casts), so this PR pins the fix commit a1c8a2fc and leaves a note to move to v0.12.0 once it is released.

Going from v0.10.1 to a1c8a2fc only adds to the public API: an aarch64 poe bit and the INTEL_LNL/INTEL_ARL/AMD_ZEN5 microarchitecture enums. VecSim only calls GetX86Info/GetAarch64Info and reads feature bits.

Verification (x86, Release -O3 -fsanitize=undefined -fno-sanitize-recover=all, alignment checking on): a small program calling only GetX86Info, built through this cmake/cpu_features.cmake:

  • v0.10.1: exit 1, the misaligned-load report above
  • a1c8a2fc: exit 0, no UBSan reports

Which issues this PR fixes

  1. Undefined Behavior (Alignment Error) in IsVendor google/cpu_features#456, Undefined Behavior (Alignment Error) in SetVendor google/cpu_features#457 (upstream reports)

Main objects this PR modified

  1. cmake/cpu_features.cmake: GIT_TAG v0.10.1 → a1c8a2fcf49d534799b966c63e0b2124cd2f60ae

Mark if applicable

  • This PR introduces API changes
  • This PR introduces serialization changes

🤖 Generated with Claude Code


Note

Low Risk
Single CMake dependency pin change with a targeted upstream bugfix; VecSim continues to use only existing feature-detection entry points.

Overview
Updates the FetchContent pin for google/cpu_features in cmake/cpu_features.cmake from v0.10.1 to commit a1c8a2fcf49d534799b966c63e0b2124cd2f60ae, with comments noting this is v0.11.0 plus upstream #458 (fixes misaligned loads in IsVendor/SetVendor that break UBSan in GetX86Info) and a reminder to switch to v0.12.0 when released.

This unblocks undefined-behavior sanitizer builds of VecSim code paths that detect CPU features via GetX86Info/GetAarch64Info; the dependency bump only adds minor new public API surface (extra aarch64/x86 enums) beyond what VecSim currently reads.

Reviewed by Cursor Bugbot for commit 7b869cc. Bugbot is set up for automated code reviews on this repo. Configure here.

cpu_features v0.10.1 (and v0.11.0) read the CPUID vendor strings through
unaligned uint32_t casts in IsVendor/SetVendor, which UBSan reports as a
misaligned load from GetX86Info. Upstream fixed it with memcpy in
google/cpu_features#458, which is not in any release yet, so pin that
commit. The public API delta from v0.10.1 is additive only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dor-forer

Copy link
Copy Markdown
Collaborator Author

Closing: VecSim now lives in RediSearch under src/vecsim/, so this fix moved to RediSearch/RediSearch#12376 (MOD-21325).

@dor-forer dor-forer closed this Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.54%. Comparing base (eefc4e7) to head (7b869cc).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1127      +/-   ##
==========================================
- Coverage   97.56%   97.54%   -0.02%     
==========================================
  Files         157      157              
  Lines       10019    10019              
==========================================
- Hits         9775     9773       -2     
- Misses        244      246       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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