Skip to content

Fix/rust move semantics#704

Open
madmax983 wants to merge 1 commit intounum-cloud:main-devfrom
madmax983:fix/rust-move-semantics
Open

Fix/rust move semantics#704
madmax983 wants to merge 1 commit intounum-cloud:main-devfrom
madmax983:fix/rust-move-semantics

Conversation

@madmax983
Copy link

@madmax983 madmax983 commented Jan 15, 2026

fix(rust): call reserve() after heap allocation to prevent segfaults

Calling reserve() on stack-allocated index before moving to heap stores dangling pointers, causing crashes when Index is used in Rust structs, Box, Arc, or any moved context.

Move reserve() call to wrap() function after heap allocation.

Just as a reference this came up with trying to implement usearch in https://github.com/madmax983/GallifreyDB to replace hnsw_rs.

@madmax983 madmax983 force-pushed the fix/rust-move-semantics branch 2 times, most recently from 30173d7 to e978d87 Compare February 17, 2026 16:32
@madmax983 madmax983 force-pushed the fix/rust-move-semantics branch from 1fd0268 to a969821 Compare February 17, 2026 16:37
@madmax983
Copy link
Author

Reworked it, let me know if this way is better?

@ashvardanian
Copy link
Contributor

Thanks, @madmax983! I'll double check in a couple of days and will be happy to merge if everything is optimal 🤗

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