Skip to content

fix(change_metric_kind): refuse missing metrics#760

Merged
ashvardanian merged 1 commit into
unum-cloud:main-devfrom
desertfury:fix/fuzz-change-metric-null
May 24, 2026
Merged

fix(change_metric_kind): refuse missing metrics#760
ashvardanian merged 1 commit into
unum-cloud:main-devfrom
desertfury:fix/fuzz-change-metric-null

Conversation

@desertfury
Copy link
Copy Markdown
Contributor

usearch_change_metric_kind forwarded the result of metric_punned_t::builtin straight into the index even when the new metric was "missing" (e.g. haversine with a non-2 dimensionality). The next search_ / filtered_search then invoked a null function pointer through invoke_array_array_third — ASAN: SEGV reading from address 0.

Checks new_metric.missing() first and reports an error instead.

@ashvardanian ashvardanian force-pushed the fix/fuzz-change-metric-null branch from 76c182a to e1c4afd Compare May 23, 2026 23:54
@desertfury desertfury force-pushed the fix/fuzz-change-metric-null branch from e1c4afd to 88ec541 Compare May 24, 2026 10:32
`usearch_change_metric_kind` could install a missing builtin metric when the requested kind was incompatible with the index dimensions or scalar kind. The next operation would then dispatch through a null metric function pointer.

Reject missing metrics before replacing the active metric, and mirror the same validation in the callback-based C entry point. The existing `try_change_metric` path still handles cast-buffer growth failures separately.

Co-authored-by: Mikhail Chichvarin <6496186+desertfury@users.noreply.github.com>

Co-authored-by: Mikhail Chichvarin <desertfury@nebius.com>

Co-authored-by: Ash Vardanian <1983160+ashvardanian@users.noreply.github.com>
@ashvardanian ashvardanian force-pushed the fix/fuzz-change-metric-null branch from 88ec541 to adf85de Compare May 24, 2026 11:38
@ashvardanian ashvardanian changed the base branch from main to main-dev May 24, 2026 11:43
@ashvardanian ashvardanian merged commit 490c1b2 into unum-cloud:main-dev May 24, 2026
ashvardanian pushed a commit that referenced this pull request May 24, 2026
### Patch

- Fix: Refuse operations without reserved thread contexts (#757) (b8d3403)
- Fix: Checked arithmetic for allocation sizes (#763) (89da7c5)
- Fix: Preserve hash lookup capacity across thread reserves (#765) (3cf843b)
- Fix: Guard quantized casts against zero-magnitude inputs (#758) (0c903f4)
- Fix: Refuse missing metrics in C change-metric API (#760) (490c1b2)
- Fix: Short-circuit self-renames (#761) (830f31a)
- Fix: Keep `vectors_lookup_` capacity after `clear()` #759 (9d77be5)
- Improve: Serialize concurrent same-`Index` Python access with a mutex (47528b5)
- Improve: Test GIL-release contract and progress-callback path (a598493)
- Improve: Release Python GIL during long index operations (d8be67d)
- Fix: Restore `ring_gt::try_push` return value (18c44ee)
- Fix: Stop JavaScript `Remove` loop after exception throw (f3e1052)
- Fix: Stop `usearch_init` on `make` failure (2aa0070)
- Fix: Stop C-ABI metadata readers on failure (34889ee)
- Fix: Report OOM from C-ABI thread-limit changers (ad24056)
- Fix: Bounded probe in `equal_iterator_gt::operator++` (b779c47)
- Fix: Resize cast buffer in `change_metric` for new bytes-per-vector (d544745)
- Fix: Eager-reserve thread contexts in `index_dense_gt::make` (#755) (b296566)
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