Skip to content

Contracts & Harnesses for len, is_empty, is_aligned, and is_aligned_to - #128

Merged
carolynzech merged 12 commits into
model-checking:mainfrom
danielhumanmod:jimmy/ptr_align
Nov 25, 2024
Merged

carolynzech merged 12 commits into
model-checking:mainfrom
danielhumanmod:jimmy/ptr_align

Conversation

@Jimmycreative

@Jimmycreative Jimmycreative commented Oct 22, 2024 •

Copy link
Copy Markdown

Towards #53

Changes
added contract and harness for len, is_empty, is_aligned, and is_aligned_to in the non-null library.

Complete - 4 successfully verified harnesses, 0 failures, 4 total.

@Jimmycreative
Jimmycreative requested a review from a team as a code owner October 22, 2024 05:09

@celinval celinval left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Awesome! I just have a few high level comments:

  1. Can you please use safety::ensures and safety::requires instead of kani ones?
  2. Can you also check the tests with dangling pointers? For example, you could use PointerGenerator, or multiple harnesses.

Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
@QinyuanWu

Copy link
Copy Markdown

Awesome! I just have a few high level comments:

  1. Can you please use safety::ensures and safety::requires instead of kani ones?
  2. Can you also check the tests with dangling pointers? For example, you could use PointerGenerator, or multiple harnesses.

@Jimmycreative See pointer generator documentation here: https://model-checking.github.io/kani/crates/doc/kani/struct.PointerGenerator.html

Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved

@celinval celinval left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you!

Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved
Comment thread library/core/src/ptr/non_null.rs Resolved

@celinval celinval left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It looks good. Can you please ensure that calling is_aligned_to with a invalid alignment value (not power of two) will not trigger UB. One way you could do that is to write a regular harness, i.e., a #[kani::proof] instead of #[kani::proof_for_contract(<func>)] so Kani does not assume the pre-condition. If the harness fails due to panic, you can add a #[kani::should_panic] to the harness.

Comment thread library/core/src/ptr/non_null.rs Resolved

@celinval celinval left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks good! Thanks

@carolynzech carolynzech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice job! Once you fix the conflicts, please @ me so that I can trigger the merge workflow.

Comment thread library/core/src/ptr/non_null.rs Resolved
@carolynzech
carolynzech enabled auto-merge (squash) November 25, 2024 15:54

@carolynzech carolynzech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

trigger merge workflow

@carolynzech
carolynzech merged commit 5e44e6e into model-checking:main Nov 25, 2024
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.

5 participants