Skip to content

Commit d37c183

Browse files
Add Challenge 19: Safety of RawVec (#314)
This PR adds Challenge 19: Safety of RawVec By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Michael Tautschnig <[email protected]> Co-authored-by: Michael Tautschnig <[email protected]>
1 parent c8aeb5b commit d37c183

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed

doc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
- [16: Verify the safety of Iterator functions](./challenges/0016-iter.md)
3333
- [17: Verify the safety of slice functions](./challenges/0017-slice.md)
3434
- [18: Verify the safety of slice iter functions](./challenges/0018-slice-iter.md)
35+
- [19: Safety of `RawVec`](./challenges/0019-rawvec.md)
3536
- [20: Verify the safety of char-related functions in str::pattern](./challenges/0020-str-pattern-pt1.md)
3637
- [21: Verify the safety of substring-related functions in str::pattern](./challenges/0021-str-pattern-pt2.md)
3738
- [22: Verify the safety of str iter functions](./challenges/0022-str-iter.md)

doc/src/challenges/0019-rawvec.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Challenge 25: Verify the safety of `RawVec` functions
2+
3+
- **Status:** Open
4+
- **Tracking Issue:** [#283](https://github.com/model-checking/verify-rust-std/issues/283)
5+
- **Start date:** *2025-03-07*
6+
- **End date:** *2025-10-17*
7+
- **Reward:** *10000 USD*
8+
9+
-------------------
10+
11+
12+
## Goal
13+
14+
Verify the safety of `RawVec` functions in (library/alloc/src/raw_vec/mod.rs).
15+
16+
## Motivation
17+
18+
`RawVec` is the type of the main component of both `Vec` and `VecDeque`: the buffer. Therefore, the safety of the functions of `Vec` and `VecDeque` depend on the safety of `RawVec`.
19+
20+
### Success Criteria
21+
22+
Verify the safety of the following functions in (library/alloc/src/raw_vec/mod.rs):
23+
24+
Write and prove the contract for the safety of the following unsafe functions:
25+
26+
| Function |
27+
|---------|
28+
|new_cap|
29+
|into_box|
30+
|from_raw_parts_in|
31+
|from_nonnull_in|
32+
|set_ptr_and_cap|
33+
|shrink_unchecked|
34+
|deallocate|
35+
36+
Prove the absence of undefined behavior for following safe abstractions:
37+
38+
| Function |
39+
|---------|
40+
|drop|
41+
|new_in|
42+
|with_capacity_in|
43+
|try_allocate_in|
44+
|current_memory|
45+
|try_reserve|
46+
|try_reserve_exact|
47+
|grow_amortized|
48+
|grow_exact|
49+
|shrink|
50+
|finish_grow|
51+
52+
The verification must be unbounded---it must hold for slices of arbitrary length.
53+
54+
The verification must hold for generic type `T` (no monomorphization).
55+
56+
### List of UBs
57+
58+
All proofs must automatically ensure the absence of the following undefined behaviors [ref](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):
59+
60+
* Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer.
61+
* Reading from uninitialized memory except for padding or unions.
62+
* Mutating immutable bytes.
63+
* Producing an invalid value
64+
65+
66+
Note: All solutions to verification challenges need to satisfy the criteria established in the [challenge book](../general-rules.md)
67+
in addition to the ones listed above.

0 commit comments

Comments
 (0)