Challenge 4: Memory safety of BTreeMap's btree::node
module
- Status: Open
- Tracking Issue: #77
- Start date: 2024/07/01
- End date: 2025/04/10
- Reward: 10,000 USD
Goal
Verify the memory safety of the alloc::collections::btree::node
module.
This is one of the main modules used for implementing the BTreeMap
collection, and it includes a lot of unsafe code.
Success Criteria
The memory safety of all public functions (especially safe ones) containing unsafe code must be verified, e.g.:
LeafNode::new
NodeRef::as_internal_mut
NodeRef::len
NodeRef::ascend
NodeRef::first_edge
NodeRef::last_edge
NodeRef::first_kv
NodeRef::last_kv
NodeRef::into_leaf
NodeRef::keys
NodeRef::as_leaf_mut
NodeRef::into_leaf_mut
NodeRef::as_leaf_dying
NodeRef::pop_internal_level
NodeRef::push
Handle::left_edge
Handle::right_edge
Handle::left_kv
Handle::right_kv
Handle::descend
Handle::into_kv
Handle::key_mut
Handle::into_val_mut
Handle::into_kv_mut
Handle::into_kv_valmut
Handle::kv_mut
Verification must be unbounded for functions that use recursion or contain loops, e.g.
NodeRef::new_internal
Handle::insert_recursing
BalancingContext::do_merge
BalancingContext::merge_tracking_child_edge
BalancingContext::steal_left
BalancingContext::steal_right
BalancingContext::bulk_steal_left
BalancingContext::bulk_steal_right
List of UBs
All proofs must automatically ensure the absence of the following undefined behaviors:
- Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer.
- Reading from uninitialized memory.
- Mutating immutable bytes.
- Producing an invalid value
Note: All solutions to verification challenges need to satisfy the criteria established in the challenge book in addition to the ones listed above.