-
Notifications
You must be signed in to change notification settings - Fork 269
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
CBMC contracts crash when dynamic allocation is not in the harness. #8317
Comments
There seems to be an issue in CBMC contracts implementation that it assumes that `free` must have a body. However, slicing can remove `free` body if the harness does not allocate anything. diffblue/cbmc#8317 We used to create an empty Box before to force `free` to be in scope. Instead, just invoke `free(NULL)` which is a no-op. 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: Jaisurya Nanduri <91620234+jaisnan@users.noreply.github.com>
I am sorry, I don't understand how to reproduce this. Where can I find that |
Contracts instrumentation attempts to load CF here:
The contracts instrumentation assumes that if an entry for a library function like |
The output mentioning builtin-library-free suggests it is loaded, so I’m quite confused what is actually going on here. Needs details to reproduce and debug. |
This is an extract of // Declare functions instead of importing more headers in order to avoid conflicting definitions.
// See https://github.com/model-checking/kani/issues/1774 for more details.
void free(void *ptr);
void *memcpy(void *dst, const void *src, size_t n);
void *calloc(size_t nmemb, size_t size); Could these declarations result in an entry being present for |
|
CBMC currently needs
free
to be in scope. In order to enforce this, Kani currently creates an empty Box before to force free to be in scope.The workaround on Kani's side looks like this,
When we remove the culprit line
let _ = std::boxed::Box::new(0_usize);
. We get the following error from CBMC:CBMC version: 5.95.1
Operating system: Both Ubuntu 22.04.4
Exact command line resulting in the issue:
"kani" "/home/ubuntu/kani/tests/expected/function-contract/gcd_rec_contract_fail.rs" "-Zfunction-contracts"
The text was updated successfully, but these errors were encountered: