-
Notifications
You must be signed in to change notification settings - Fork 283
Require explicit contract for --replace-call-with-contract #8739
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
base: develop
Are you sure you want to change the base?
Require explicit contract for --replace-call-with-contract #8739
Conversation
fa3ad0a to
ed4f99b
Compare
Change --replace-call-with-contract to produce a hard error instead of a
warning when used with functions lacking explicit contracts. This
change addresses a soundness issue where CBMC would previously assume a
trivial contract automatically.
Users that really need a trivial contract with no constraints should use
````c
int my_function(int x)
__CPROVER_requires(1)
__CPROVER_ensures(1)
{
return x + 1;
}
````
Fixes: diffblue#8728
ed4f99b to
2a32be7
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8739 +/- ##
===========================================
- Coverage 79.94% 79.94% -0.01%
===========================================
Files 1699 1699
Lines 187790 187786 -4
Branches 73 73
===========================================
- Hits 150133 150122 -11
- Misses 37657 37664 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Check if the function actually has a contract | ||
| // If not, produce a hard error for soundness | ||
| const symbolt *contract_sym; | ||
| if(ns.lookup("contract::" + id2string(target_function), contract_sym)) | ||
| { | ||
| // no contract provided in the source - this is a soundness issue | ||
| // when using --replace-call-with-contract | ||
| throw invalid_input_exceptiont( | ||
| "Function '" + id2string(target_function) + | ||
| "' does not have a contract. " + | ||
| "When using --replace-call-with-contract, a contract must be " | ||
| "explicitly " + | ||
| "provided. If you need a trivial contract, please add explicit " + | ||
| CPROVER_PREFIX "requires and " CPROVER_PREFIX | ||
| "ensures clauses to the function."); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this check be place before get_contract?
Change --replace-call-with-contract to produce a hard error instead of a warning when used with functions lacking explicit contracts. This change addresses a soundness issue where CBMC would previously assume a trivial contract automatically.
Users that really need a trivial contract with no constraints should use
Fixes: #8728