Skip to content

Fix data race on lazy initialization of function pointers in SimSIMD dispatch - #26

Merged
vitlibar merged 1 commit into
ClickHouse/v6.5.15from
fix-data-race-on-lazy-init
Apr 9, 2026
Merged

vitlibar merged 1 commit into
ClickHouse/v6.5.15from
fix-data-race-on-lazy-init

Conversation

@vitlibar

@vitlibar vitlibar commented Apr 8, 2026 •

Copy link
Copy Markdown
Member

Fix data race on lazy initialization of function pointers in SimSIMD dispatch

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a data race in SimSIMD’s dynamic-dispatch layer by making the lazy initialization of cached function pointers (and cached CPU capability detection) thread-safe.

Changes:

  • Added C11 atomics (<stdatomic.h>) to protect lazy-initialized cached metric/kernel function pointers in dispatch wrappers.
  • Made simsimd_capabilities() cache atomic to avoid races during capability detection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread c/lib.c Resolved
Comment thread c/lib.c Resolved
Comment thread c/lib.c Resolved
Comment thread c/lib.c Resolved
@vitlibar
vitlibar merged commit e81e1c2 into ClickHouse/v6.5.15 Apr 9, 2026
4 checks passed
@vitlibar
vitlibar deleted the fix-data-race-on-lazy-init branch April 9, 2026 09:41
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.

2 participants