forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 53
Add a challenge for linked_list
#30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
qinheping
merged 3 commits into
model-checking:main
from
qinheping:challenge/linked-list
Jul 10, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Challenge 5: Verify functions iterating over inductive data type: `linked_list` | ||
|
||
- **Status:** Open | ||
- **Tracking Issue:** [Link to issue](https://github.com/model-checking/verify-rust-std/issues/29) | ||
- **Start date:** *24/07/01* | ||
- **End date:** *24/12/10* | ||
|
||
------------------- | ||
|
||
|
||
## Goal | ||
|
||
Verify the memory safety of [`alloc::collections::linked_list` functions](https://github.com/rust-lang/rust/blob/c290e9de32e8ba6a673ef125fde40eadd395d170/library/alloc/src/collections/linked_list.rs) that iterate the its internal inductive-defined data type. | ||
|
||
### Details | ||
|
||
The internal representations of `linked_list` are bi-direction linked list nodes. To unboundedly prove the memory safety of functions that iterating over such inductive-defined data type, we need to illustrate the memory safety for linked lists of arbitrary shape. On the other hand, if we can only prove the memory safety for certain shapes of linked lists, how should we specify the precondition---the assumptions on the shape of the inductive-defined data type---of such functions. | ||
|
||
|
||
### Success Criteria | ||
|
||
The memory safety of the following public functions that iterating over the internal inductive data type must be verified: | ||
|
||
| Function | Location | | ||
|---------|---------| | ||
|clearn | alloc::collections::linked_list | | ||
|contains| alloc::collections::linked_list | | ||
|split_off| alloc::collections::linked_list | | ||
|remove| alloc::collections::linked_list | | ||
|retain| alloc::collections::linked_list | | ||
|retain_mut| alloc::collections::linked_list | | ||
|extract_if| alloc::collections::linked_list | | ||
|
||
|
||
The verification must be unbounded---it must hold for linked lists of arbitrary shape. | ||
|
||
It is OK to assume that the generic type `T` of the proofs is primitive types, e.g., `i32`, `u32`, `bool`, etc. | ||
|
||
### List of UBs | ||
|
||
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): | ||
|
||
* Accessing (loading from or storing to) a place that is dangling or based on a misaligned pointer. | ||
* Reading from uninitialized memory except for padding or unions. | ||
* Mutating immutable bytes. | ||
* Producing an invalid value | ||
|
||
|
||
Note: All solutions to verification challenges need to satisfy the criteria established in the [challenge book](../general-rules.md) | ||
in addition to the ones listed above. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.