Skip to content

Commit 7dd01bb

Browse files
Add challenge 23 24 for Vec (#267)
This PR add 2 challenges for Vec - Challenge 23: functions in mod.rs - Challenge 24: other functions 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: Carolyn Zech <[email protected]>
1 parent 731bb1e commit 7dd01bb

File tree

3 files changed

+147
-0
lines changed

3 files changed

+147
-0
lines changed

doc/src/SUMMARY.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@
3636
- [20: Verify the safety of char-related functions in str::pattern](./challenges/0020-str-pattern-pt1.md)
3737
- [21: Verify the safety of substring-related functions in str::pattern](./challenges/0021-str-pattern-pt2.md)
3838
- [22: Verify the safety of str iter functions](./challenges/0022-str-iter.md)
39+
- [23: Verify the safety of Vec functions part 1](./challenges/0023-vec-pt1.md)
40+
- [24: Verify the safety of Vec functions part 2](./challenges/0024-vec-pt2.md)
3941
- [25: Verify the safety of `VecDeque` functions](./challenges/0025-vecdeque.md)

doc/src/challenges/0023-vec-pt1.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Challenge 23: Verify the safety of `Vec` functions part 1
2+
3+
- **Status:** Open
4+
- **Tracking Issue:** [#284](https://github.com/model-checking/verify-rust-std/issues/284)
5+
- **Start date:** *2025-03-07*
6+
- **End date:** *2025-10-17*
7+
- **Reward:** *15000 USD*
8+
9+
-------------------
10+
11+
12+
## Goal
13+
14+
Verify the safety of `std::Vec` functions (library/alloc/src/vec/mod.rs).
15+
16+
17+
### Success Criteria
18+
19+
Verify the safety of the following public functions in (library/alloc/src/vec/mod.rs):
20+
21+
| Function |
22+
|---------|
23+
|from_raw_parts|
24+
|from_nonnull|
25+
|from_nonnull_in|
26+
|into_raw_parts_with_alloc|
27+
|into_boxed_slice|
28+
|truncate|
29+
|set_len|
30+
|swap_remove|
31+
|insert|
32+
|remove|
33+
|retain_mut|
34+
|dedup_by|
35+
|push|
36+
|push_within_capacity|
37+
|pop|
38+
|append|
39+
|append_elements|
40+
|drain|
41+
|clear|
42+
|split_off|
43+
|leak|
44+
|spare_capacity_mut|
45+
|split_at_spare_mut|
46+
|split_at_spare_mut_with_len|
47+
|extend_from_within|
48+
|into_flattened|
49+
|extend_with|
50+
|spec_extend_from_within|
51+
|deref|
52+
|deref_mut|
53+
|into_iter|
54+
|extend_desugared|
55+
|extend_trusted|
56+
|extract_if|
57+
|drop|
58+
|try_from|
59+
60+
61+
62+
63+
The verification must be unbounded---it must hold for slices of arbitrary length.
64+
65+
The verification must hold for generic type `T` (no monomorphization).
66+
67+
### List of UBs
68+
69+
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):
70+
71+
* Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer.
72+
* Reading from uninitialized memory except for padding or unions.
73+
* Mutating immutable bytes.
74+
* Producing an invalid value
75+
76+
77+
Note: All solutions to verification challenges need to satisfy the criteria established in the [challenge book](../general-rules.md)
78+
in addition to the ones listed above.

doc/src/challenges/0024-vec-pt2.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Challenge 24: Verify the safety of `Vec` functions part 2
2+
3+
- **Status:** Open
4+
- **Tracking Issue:** [#285](https://github.com/model-checking/verify-rust-std/issues/285)
5+
- **Start date:** *2025/03/07*
6+
- **End date:** *2025/10/17*
7+
- **Reward:** *15000 USD*
8+
9+
-------------------
10+
11+
12+
## Goal
13+
14+
Continue from part 1 (Challenge 23), for this challenge, you need to verify the safety of `std::Vec` iterator functions in other files in (library/alloc/src/vec/).
15+
16+
17+
### Success Criteria
18+
19+
Verify the safety of the following functions that in implemented for `IntoIter` in (library/alloc/src/vec/into_iter.rs):
20+
21+
| Function |
22+
|---------|
23+
|as_slice|
24+
|as_mut_slice|
25+
|forget_allocation_drop_remaining|
26+
|into_vecdeque|
27+
|next|
28+
|size_hint|
29+
|advance_by|
30+
|next_chunk|
31+
|fold|
32+
|try_fold|
33+
|__iterator_get_unchecked|
34+
|next_back|
35+
|advance_back_by|
36+
|drop|
37+
38+
and the following functions from other files:
39+
40+
| Function | in File|
41+
|---------|---------|
42+
|next| extract_if.rs|
43+
|spec_extend (for IntoIter) | spec_extend.rs |
44+
|spec_extend (for slice::Iter) | spec_extend.rs |
45+
|from_elem (for i8)| spec_from_elem.rs |
46+
|from_elem (for u8)| spec_from_elem.rs |
47+
|from_elem (for ())| spec_from_elem.rs |
48+
|from_iter| spec_from_iter.rs|
49+
|from_iter (default)| spec_from_iter_nested.rs|
50+
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)