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

Add loop contracts and harness for small_slice_eq #122

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

Conversation

qinheping
Copy link

@qinheping qinheping commented Oct 19, 2024

Porting from https://github.com/model-checking/kani/blob/main/tests/expected/loop-contract/small_slice_eq.rs

The cbmc argument --object-bits 8 is needed to avoid running out of memory for the harness.

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

@qinheping qinheping requested a review from a team as a code owner October 19, 2024 05:14
@qinheping
Copy link
Author

The method small_slice_eq and the harness only runs for configuration target_arch = "x86_64" and target_feature = "sse2", and hence is not tested in the current CI checks.

Copy link

@celinval celinval left a comment

Choose a reason for hiding this comment

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

Can you also please add a contract to this function since it is unsafe?

library/core/src/str/pattern.rs Outdated Show resolved Hide resolved
library/core/src/str/pattern.rs Show resolved Hide resolved
@qinheping qinheping force-pushed the loop-contracts/small_slice_eq branch from 365d85c to d3ef481 Compare October 24, 2024 18:36
github-merge-queue bot pushed a commit to model-checking/kani that referenced this pull request Oct 29, 2024
Move `any_slice_from_array` to `kani_core` so that we can call them in
verify-rust-std (an example harness in
model-checking/verify-rust-std#122).

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
@@ -230,6 +230,7 @@
#![feature(unboxed_closures)]
#![feature(unsized_fn_params)]
#![feature(with_negative_coherence)]
#![feature(proc_macro_hygiene)]
Copy link

Choose a reason for hiding this comment

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

why do we need this? I would prefer not enabling any new feature in the standard library

Copy link
Author

Choose a reason for hiding this comment

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

It is required to use macro for loops.

Copy link
Author

Choose a reason for hiding this comment

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

Error I got without the feature suggests to include it.

error[E0658]: custom attributes cannot be applied to expressions
  --> simple_while_loop_not_enabled.rs:15:5
   |
15 |     #[kani::loop_invariant(x >= 2)]
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #54727 <https://github.com/rust-lang/rust/issues/54727> for more information
   = help: add `#![feature(proc_macro_hygiene)]` to the crate attributes to enable
   = note: this compiler was built on 2024-11-02; consider upgrading it if it is out of date

library/core/src/str/pattern.rs Outdated Show resolved Hide resolved
library/core/src/str/pattern.rs Show resolved Hide resolved
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.

2 participants