You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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]>
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)
0 commit comments