3 unstable releases

new 0.2.1 Oct 31, 2024
0.2.0 Sep 30, 2024
0.1.0 Sep 3, 2024

#273 in Data structures

Download history 108/week @ 2024-08-30 26/week @ 2024-09-06 28/week @ 2024-09-13 23/week @ 2024-09-20 178/week @ 2024-09-27 35/week @ 2024-10-04 13/week @ 2024-10-11 10/week @ 2024-10-18 116/week @ 2024-10-25

197 downloads per month
Used in 37 crates (5 directly)

MIT/Apache

51KB
831 lines

slotmap-careful: Wrapper for slotmap generational arena to prevent key reuse.

The slotmap generational arena implementation is efficient and easy to use. Unfortunately, it has a behavior where if a single index slot is reused about 2^31 times, its version field will wrap around, and the same key will be returned twice. This can lead to security problems in programs that rely on each for a slotmap being permanently unique.

This crate implement a wrapper around slotmap::SlotMap to prevent key reuse. It works by noticing when any slot with a very high version counter is about to become empty, and instead marking such slots as permanently unusable.

Note that this new behavior can result in memory usage that grows slowly over time, even if the actual capacity of the slotmap remains low.


lib.rs:

Dependencies

~0.7–1.3MB
~27K SLoC