Skip to content

Conversation

carolynzech
Copy link

Adds an Invariant trait to core::ub_checks, and adds two invariants for Alignment and Layout.

One call-out: Kani's invariant trait enforces that the type is sized, but I wasn't sure why that would be necessary, so I didn't add it here.

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

@carolynzech carolynzech requested a review from a team as a code owner September 18, 2024 17:10
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.

Thanks @carolynzech !

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 please also add empty implementations for the Invariant trait for the primitive types?

Copy link
Member

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Thank you!

Co-authored-by: Celina G. Val <[email protected]>
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 please remove the unsafe code.

@feliperodri feliperodri added the Maintenance Maintenance related issues for the challange label Oct 8, 2024
celinval
celinval previously approved these changes Oct 24, 2024
Carolyn Zech and others added 2 commits October 24, 2024 19:40
@carolynzech carolynzech requested a review from celinval October 25, 2024 11:00
@carolynzech carolynzech dismissed celinval’s stale review October 25, 2024 11:00

Re-requesting review because I added an enum implementation.

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.

Thanks

@carolynzech carolynzech enabled auto-merge (squash) October 30, 2024 14:15
Copy link

@jaisnan jaisnan left a comment

Choose a reason for hiding this comment

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

Ty

@carolynzech carolynzech merged commit abe2354 into model-checking:main Oct 30, 2024
9 checks passed
@carolynzech carolynzech deleted the invariant branch October 30, 2024 15:47
github-merge-queue bot pushed a commit that referenced this pull request Dec 11, 2024
…ion (#136)

Resolves #72 

We added invariants for Nanoseconds and Duration to match the safety
conditions for those types.

We add safety requirements to the following methods:
- `new`, `from_secs`, `from_millis`, `from_micros`, `from_nanos`,
`as_secs`, `as_millis`, `as_micros`, `as_nanos`, `subsec_millis`,
`subsec_micros`, `subsec_nanos`, `checked_add`, `checked_sub`,
`checked_mul`, `checked_div`

We additionally add correctness conditions to the following methods:
- `from_secs`, `as_secs`, `subsec_millis`, `subsec_micros`,
`subsec_nanos`, `as_millis`, `as_micros`

Support for `kani::Invariant` depends on #87. For the interim we
implemented a proxy trait `TempInvariant` that exposes the same
`is_safe` method. We will update this once #87 is merged.

While the safety check for `Duration::as_nanos()` succeeds, we ran into
timeouts for `Duration::as_nanos()` when we tried to use a correctness
contract and we're looking for advice on how to speed up that
verification time. We were able to prove it for `u16::MAX`, but hit
timeouts for larger numbers.

We are unsure if the pre-conditions for `Duration::new()` are acceptable
because they limit the range of values that you can call
`Duration::new()` with. However, we think it's reasonable since we limit
the values to values that don't panic. Let us know if this is a thing
that we should change.

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

---------

Co-authored-by: Cole Vick <[email protected]>
Co-authored-by: Celina G. Val <[email protected]>
Co-authored-by: Michael Tautschnig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Maintenance Maintenance related issues for the challange

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants