4 releases

new 0.2.2 Dec 2, 2024
0.2.1 Oct 31, 2024
0.2.0 Sep 30, 2024
0.1.0 Sep 3, 2024

#223 in Data structures

Download history 117/week @ 2024-08-31 19/week @ 2024-09-07 29/week @ 2024-09-14 22/week @ 2024-09-21 190/week @ 2024-09-28 23/week @ 2024-10-05 12/week @ 2024-10-12 10/week @ 2024-10-19 178/week @ 2024-10-26 963/week @ 2024-11-02 262/week @ 2024-11-09 1067/week @ 2024-11-16 924/week @ 2024-11-23 1160/week @ 2024-11-30

3,421 downloads per month
Used in 40 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.6–1.2MB
~26K SLoC