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

Atomic Types Challenge #82

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

Conversation

carolynzech
Copy link

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


In addition to any properties called out as SAFETY comments in the source code, all proofs must automatically ensure the absence of the following [undefined behaviors](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):

* Data races.
Copy link
Author

Choose a reason for hiding this comment

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

Note that adding data races means that we cannot complete this challenge with Kani. I can take this out if we'd prefer to leave data races out of scope for this challenge. Not sure the feasibility of adding a tool later that can reason about this.

Copy link
Member

Choose a reason for hiding this comment

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

The underlying CBMC supports concurrency, so perhaps Kani can do it?

Choose a reason for hiding this comment

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

I think in principle we should keep this, since that is the main safety property of many safety guarantees offered by the type.

It's not clear to me what forms these proofs would take.

doc/src/challenges/0007-atomic-types.md Outdated Show resolved Hide resolved
doc/src/challenges/0007-atomic-types.md Outdated Show resolved Hide resolved
doc/src/challenges/0007-atomic-types.md Outdated Show resolved Hide resolved
doc/src/challenges/0007-atomic-types.md Outdated Show resolved Hide resolved
doc/src/challenges/0007-atomic-types.md Outdated Show resolved Hide resolved

In addition to any properties called out as SAFETY comments in the source code, all proofs must automatically ensure the absence of the following [undefined behaviors](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):

* Data races.
Copy link
Member

Choose a reason for hiding this comment

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

The underlying CBMC supports concurrency, so perhaps Kani can do it?

doc/src/challenges/0007-atomic-types.md Outdated Show resolved Hide resolved
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! Is there any usage of the unsafe functions in the standard library that is worth including in the challenge?

doc/src/challenges/0007-atomic-types.md Outdated Show resolved Hide resolved

In addition to any properties called out as SAFETY comments in the source code, all proofs must automatically ensure the absence of the following [undefined behaviors](https://github.com/rust-lang/reference/blob/142b2ed77d33f37a9973772bd95e6144ed9dce43/src/behavior-considered-undefined.md):

* Data races.

Choose a reason for hiding this comment

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

I think in principle we should keep this, since that is the main safety property of many safety guarantees offered by the type.

It's not clear to me what forms these proofs would take.

doc/src/challenges/0007-atomic-types.md Show resolved Hide resolved
- `atomic_umax`
- `atomic_umin`

These functions are wrappers around compiler intrinsics. Thus, your task is to ensure that we cannot cause undefined behavior by invoking the intrinsics on these inputs. For instance, if the intrinsic takes as input a raw pointer and reads the value at that pointer, your contracts should ensure that we would not cause UB by performing the read. For the purpose of this challenge, you may assume that any UB in the intrinsics would be a direct consequence of malformed inputs.

Choose a reason for hiding this comment

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

Maybe this challenge should include writing contracts for those intrinsics and ensuring that the contracts are not violated by these methods.

Copy link
Author

@carolynzech carolynzech Sep 13, 2024

Choose a reason for hiding this comment

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

See comment. I can add intrinsics to this challenge as well, although we may want to be mindful of length. If we have contracts on the methods, intrinsics, and a meatier standard library application, this challenge will likely be the longest one we have. That's not necessarily bad, but I wonder if atomic intrinsics would be better as a separate challenge to keep the size of this one more manageable.

Choose a reason for hiding this comment

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

The methods are safe though.

Copy link
Author

Choose a reason for hiding this comment

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

Sure, but we still want to verify unsafe code inside safe functions, no?

@carolynzech
Copy link
Author

carolynzech commented Sep 13, 2024

Thanks @carolynzech! Is there any usage of the unsafe functions in the standard library that is worth including in the challenge?

Yes. I was erring on the side of keeping this challenge smaller, but there's some libraries that use more of the methods than ReentrantLock does. I'll add a section.
The one module that really takes advantage of these methods is MPMC. We should make a separate challenge to verify this one at some point.

@carolynzech carolynzech marked this pull request as draft September 19, 2024 14:28
@carolynzech carolynzech marked this pull request as ready for review September 19, 2024 20:42
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.

3 participants