@@ -33,28 +33,27 @@ inline void *malloc(__CPROVER_size_t malloc_size)
3333
3434 __ CPROVER_bool record_malloc = __ VERIFIER_nondet__ _ CPROVER_bool();
3535 __ CPROVER_malloc_object = record_malloc ? malloc_res : __ CPROVER_malloc_object;
36- __ CPROVER_malloc_size = record_malloc ? malloc_size : __ CPROVER_malloc_size;
3736
3837 return malloc_res;
3938}
4039```
4140
42- Both internal variables `__CPROVER_malloc_object` and `__CPROVER_malloc_size `
43- are initialized to 0 in the `__CPROVER_initialize()` function of a goto program.
44- The nondeterministic switch controls whether the address and size of the memory
45- block allocated in this particular invocation of `malloc()` are recorded.
41+ The internal variable `__CPROVER_malloc_object`
42+ is initialized to 0 in the `__CPROVER_initialize()` function of a goto program.
43+ The nondeterministic switch controls whether the address of the memory
44+ block allocated in this particular invocation of `malloc()` is recorded.
4645
4746When the option `--pointer-check` is used, cbmc generates the following
4847verification condition for each pointer dereference expression (e.g.,
4948`*pointer`):
5049
5150```C
52- __CPROVER_POINTER_OBJECT (pointer) == __CPROVER_POINTER_OBJECT(__CPROVER_malloc_object) ==>
53- __CPROVER_POINTER_OFFSET(pointer) >= 0 && __CPROVER_POINTER_OFFSET (pointer) < __CPROVER_malloc_size
51+ __CPROVER_POINTER_OFFSET (pointer) >= 0 &&
52+ __CPROVER_POINTER_OFFSET(pointer) < __CPROVER_OBJECT_SIZE (pointer)
5453```
5554
56- The primitives ` __CPROVER_POINTER_OBJECT ()` and ` __CPROVER_POINTER_OFFSET ()` extract
57- the object id, and pointer offset , respectively. Similar conditions are
55+ The primitives ` __CPROVER_POINTER_OFFSET ()` and ` __CPROVER_OBJECT_SIZE ()` extract
56+ the pointer offset and size of the object pointed to , respectively. Similar conditions are
5857generated for ` assert(__CPROVER_r_ok(pointer, size)) ` and
5958` assert(__CPROVER_w_ok(pointer, size)) ` .
6059
@@ -77,9 +76,5 @@ Here the verification condition generated for the pointer dereference should
7776fail. In the approach outlined above it indeed can, as one can choose true for
7877` __VERIFIER_nondet___CPROVER_bool() ` in the first call
7978to ` malloc() ` , and false for ` __VERIFIER_nondet___CPROVER_bool() ` in the second
80- call to ` malloc() ` . Thus, the object address and size of the first call to
81- ` malloc() ` are recorded in ` __CPROVER_malloc_object ` and ` __CPROVER_malloc_size `
82- respectively. Thus, the premise of the implication in the verification condition
83- above is true, while the conclusion is false, hence the overall condition is
84- false.
85-
79+ call to ` malloc() ` . Thus, the object address of the first call to
80+ ` malloc() ` is recorded in ` __CPROVER_malloc_object ` .
0 commit comments