-
Notifications
You must be signed in to change notification settings - Fork 277
Closed
Labels
Description
We get an error from goto-instrument when using a harness generated by goto-harness.
For example:
Take the following C file as test.c
:
#include <assert.h>
void test_fn(int *a)
__CPROVER_requires((a == nullptr) || __CPROVER_is_fresh(a, sizeof(*a)))
__CPROVER_requires((a != nullptr) ==> (*a != 5))
__CPROVER_ensures((a != nullptr) ==> (*a == 5))
__CPROVER_assigns(*a)
{
assert((a == nullptr) || (*a != 5));
if (a != nullptr) {
*a = 5;
}
}
This contract should pass validation.
When trying to generate the harness and instrument the goto, we get:
$ goto-cc -std=c23 -o test.goto test.c
$ goto-harness --harness-function-name main --harness-type call-function --function test_fn test.goto test.goto
$ goto-instrument --dfcc main --enforce-contract test_fn test.goto test.goto
Reading GOTO program from 'test.goto'
Function Pointer Removal
Virtual function removal
Cleaning inline assembler statements
Trying to force one backedge per target
Loading CPROVER C library (x86_64)
Adding the cprover_contracts library (x86_64)
file <builtin-library-malloc> line 6: symbol '__CPROVER_malloc_is_new_array' already has an initial value
symbol '__CPROVER_alloca_object' already has an initial value
symbol '__CPROVER_new_object' already has an initial value
file <builtin-library-free> line 11: symbol '__CPROVER_malloc_is_new_array' already has an initial value
file <builtin-library-__CPROVER_contracts_library> line 1077 function __CPROVER_contracts_write_set_deallocate_freeable: no body for function 'free'
No body for 'free' during inlining
Numeric exception : 0
6$
We are able to prove the contract passes if using the following manual harness:
int main(void) {
int * a;
test_fn(a);
}