|
| 1 | +# Challenge 16: Verify the safety of Iterator functions |
| 2 | + |
| 3 | +- **Status:** Open |
| 4 | +- **Tracking Issue:** [#280](https://github.com/model-checking/verify-rust-std/issues/280) |
| 5 | +- **Start date:** *2025-03-07* |
| 6 | +- **End date:** *2025-10-17* |
| 7 | +- **Reward:** *10,000 USD* |
| 8 | + |
| 9 | +------------------- |
| 10 | + |
| 11 | + |
| 12 | +## Goal |
| 13 | + |
| 14 | +Verify the safety of iter functions that are defined in (library/core/src/iter/adapters): |
| 15 | + |
| 16 | + |
| 17 | + |
| 18 | +### Success Criteria |
| 19 | + |
| 20 | +Write and prove the contract for the safety of the following unsafe functions: |
| 21 | + |
| 22 | +| Function | Defined in | |
| 23 | +|---------| ---------| |
| 24 | +|__iterator_get_unchecked| clone.rs| |
| 25 | +|next_unchecked| clone.rs| |
| 26 | +|__iterator_get_unchecked| copied.rs| |
| 27 | +|__iterator_get_unchecked| enumerate.rs| |
| 28 | +|__iterator_get_unchecked | fuse.rs| |
| 29 | +|__iterator_get_unchecked | map.rs| |
| 30 | +|next_unchecked | map.rs| |
| 31 | +|__iterator_get_unchecked | skip.rs| |
| 32 | +|__iterator_get_unchecked | zip.rs| |
| 33 | +|get_unchecked| zip.rs| |
| 34 | + |
| 35 | +Prove the absence of undefined behavior for following safe abstractions: |
| 36 | + |
| 37 | +| Function | Defined in | |
| 38 | +|---------| ---------| |
| 39 | +|next_back_remainder| array_chunks.rs| |
| 40 | +|fold| array_chunks.rs| |
| 41 | +|spec_next_chunk| copied.rs| |
| 42 | +|next_chunk_dropless| filter.rs| |
| 43 | +|next_chunk| filter_map.rs| |
| 44 | +|as_array_ref | map_windows.rs| |
| 45 | +|as_uninit_array_mut | map_windows.rs| |
| 46 | +|push | map_windows.rs| |
| 47 | +|drop | map_windows.rs| |
| 48 | +|original_step | step_by.rs| |
| 49 | +|spec_fold| take.rs| |
| 50 | +|spec_for_each| take.rs| |
| 51 | +|fold| zip.rs| |
| 52 | +|next| zip.rs| |
| 53 | +|nth| zip.rs| |
| 54 | +|next_back| zip.rs| |
| 55 | +|spec_fold| zip.rs| |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +The verification must be unbounded---it must hold for slices of arbitrary length. |
| 60 | + |
| 61 | +The verification must hold for generic type `T` (no monomorphization). |
| 62 | + |
| 63 | +### List of UBs |
| 64 | + |
| 65 | +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): |
| 66 | + |
| 67 | +* Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer. |
| 68 | +* Reading from uninitialized memory except for padding or unions. |
| 69 | +* Mutating immutable bytes. |
| 70 | +* Producing an invalid value |
| 71 | + |
| 72 | + |
| 73 | +Note: All solutions to verification challenges need to satisfy the criteria established in the [challenge book](../general-rules.md) |
| 74 | +in addition to the ones listed above. |
0 commit comments