Skip to content
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

Harnesses verifying slice types for add, sub and offset #179

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

szlee118
Copy link

Towards #76

Changes

Contracts Added:

  • Added contracts for <*mut T>::add, <*mut T>::sub, and <*mut T>::offset operations for raw pointers to slices.

Proofs Implemented:

  • Added proofs for the above contracts, verifying safety for the following slice pointee types using arrays:
  • All integer types (i8, i16, i32, etc.).
  • Tuples (composite types) (e.g., (i8, i8), (i32, f64, bool)).
  • Unit type (()).

Macro Definitions:

  • Introduced macros to simplify and automate harness generation:
  • One macro for add and sub operations on slices.
  • Another macro for offset operations on slices.

Array-Based Implementation for Slice Verification:

  • Arrays are used as a proxy for slices (as slices do not have a known length at compile time) to enable proper bounds checking and assumptions during verification.

This should be merged after another PR for dependency issues.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

xsxszab and others added 25 commits October 7, 2024 12:44
implemented integer type proof for contract for fn add, sub and offset
Combines macros for different types.
…allocation api, modified their proof for harness accordingly
@szlee118 szlee118 requested a review from a team as a code owner November 22, 2024 19:58
@szlee118 szlee118 changed the title Verify/ptr mut slice types Verify/ptr mut slice types(add, sub and offset) Nov 22, 2024
@szlee118 szlee118 changed the title Verify/ptr mut slice types(add, sub and offset) Harnesses verifying slice types for add, sub and offset Nov 22, 2024
@szlee118
Copy link
Author

@feliperodri FYI

@tautschnig
Copy link
Member

@szlee118 #113 has been merged, but now conflicts need to be resolved on this one.

@szlee118
Copy link
Author

@tautschnig @feliperodri conflict resolved.

Copy link

@feliperodri feliperodri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems there are still some conflicts. Could you check if the conflicts were successfully solved?

library/core/src/ptr/mut_ptr.rs Outdated Show resolved Hide resolved
library/core/src/ptr/mut_ptr.rs Outdated Show resolved Hide resolved
library/core/src/ptr/mut_ptr.rs Show resolved Hide resolved
library/core/src/ptr/mut_ptr.rs Show resolved Hide resolved
Comment on lines +2371 to +2372
// Constant for array size used in all tests, for performance reason
const ARRAY_SIZE: usize = 5;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't 5 too low? How is the verification performance numbers?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explained in another PR's comment that 5 is enough for this case.
This performance statement is outdated, and has been removed by newest commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants