-
Notifications
You must be signed in to change notification settings - Fork 100
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
cover_or_fail!
macro
#3424
cover_or_fail!
macro
#3424
Conversation
Thanks @carolynzech for this! It's nice to finally see a concrete implementation for this feature. I do have some thoughts about it too. I suppose you know about the very related option In my opinion, option 3 would restrict too much the usage for the macro to be useful. Option 1 seems fine to me and it's the same we were doing for |
Yes, I did see that. This implementation is subtly different in that it allows users to mix and match
I would tend to agree--it's a less messy solution for sure, but that's moot if it doesn't help users in the first place.
If I imagine myself as a user of Kani unfamiliar with the implementation, I would expect that if I put |
If we are going to have an option that warns about I'd be happy with a feature like that. We need to make sure the reachability caveat is well documented, and I'd probably use a more detailed name for the flag, but the rest sounds good to me. |
Closing for now; this feature requires further design discussion. |
This PR adds a
cover_or_fail!
macro to Kani. This macro has the same functionality as the existingcover!
macro, except it causes verification to fail when the outcome is unsatisfiable or unreachable.Currently, a caller can invoke this macro from anywhere in their code (not just harnesses), which is also true for
cover
. However, we only analyze reachability starting from a given proof harness (the entry point), so if thecover_or_fail
call is contained inside a function that the harness does not call, the verification will succeed even though the call actually is not covered. I'm concerned that this behavior will produce confusing results for users. Specifically, see the test cases insidecover-unreachable-outside-harness-pass
(which pass verification) andcover-unreachable-outside-harness-fail
(which fail verification). See also the discussion of this issue here. Is this the behavior that we want?Our options are:
cover_or_fail
throughout their code for debugging.cover_or_fail
and makes sure that CBMC marked them all as reachable. This allows usingcover_or_fail
throughout the codebase and avoids any confusing reachability behavior, but may be slow.cover_or_fail
to proof harnesses only. This approach solves the reachability issue, since CBMC will see every call tocover_or_fail
, but does restrict users--the author of the issue that prompted this PR, for example, wanted to use it outside of a proof harness.I'm leaning toward #1 or #3, but curious to hear others' thoughts.
Resolves #2792
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.