Skip to content

Mode for only verifying the absence of UB #1532

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

Open
Lysxia opened this issue May 15, 2025 · 1 comment
Open

Mode for only verifying the absence of UB #1532

Lysxia opened this issue May 15, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@Lysxia
Copy link
Collaborator

Lysxia commented May 15, 2025

There are different verification goals one may have, which result in different contracts. These are different "modes" we may want to support:

  • Creusot's currently intended goal is to prevent most panics. For example, we allow the size overflow panic in Vec::push, because that's a PITA to deal with for little gain, but we forbid the out-of-bounds panic in index.
  • Another choice is to only prevent UB, but with guarantees applicable even for unverified clients. In that case all public safe functions must have a true precondition, including panic! which is considered safe in this setting. Only unsafe and private functions may have preconditions other than true.
  • Going in the opposite direction, it's natural to imagine another mode where all panics are forbidden, even in Vec::push, which would have to have yet another contract.
  • Generalizing further, we might as well leave it entirely up to the user to decide what behaviors to forbid, defining their own modes.

In terms of implementation, I currently think that "modes" would mainly be a way to choose between different contracts. For the "no UB" mode Creusot could additionally check that public functions have no preconditions. I wonder whether this should somehow interact with #[terminating] and #[pure] attributes, or other features.

We can start with two modes to keep it simple: on top of the current "best effort" mode, I really want to add a "no UB, panics allowed" mode for the verify-rust-std challenge.

@Lysxia Lysxia added the enhancement New feature or request label May 15, 2025
@xldenis
Copy link
Collaborator

xldenis commented May 15, 2025

Do you envision modes forming a hierarchy?

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

No branches or pull requests

2 participants