Skip to content

Commit 33c9f89

Browse files
committed
goto_rw: treat dereference failure as a read/write of __CPROVER_memory
Treating any such access as an access to the single, global memory object will enable sound overapproximation, and thus helps slicing soundness.
1 parent 1b65ef9 commit 33c9f89

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
static void f(int* x) { *x = 5; }
5+
static void g(int *x) { assert(*x == 5); }
6+
7+
int main(int argc, char** argv) {
8+
9+
int *x = (int*)malloc(sizeof(int));
10+
f(x);
11+
g(x);
12+
13+
return 0;
14+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CORE
2+
main.c
3+
--full-slice --add-library
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$

src/analyses/goto_rw.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,11 @@ void rw_range_sett::get_objects_dereference(
127127
{
128128
const exprt &pointer=deref.pointer();
129129
get_objects_rec(get_modet::READ, pointer);
130+
131+
// we don't have points-to information, dereferencing will yield some
132+
// in-memory object
133+
const symbolt &memory_symbol = ns.lookup(CPROVER_PREFIX "memory");
134+
get_objects_rec(mode, memory_symbol.symbol_expr(), -1, size);
130135
}
131136

132137
void rw_range_sett::get_objects_byte_extract(
@@ -612,6 +617,13 @@ void rw_range_set_value_sett::get_objects_dereference(
612617
if(object.is_not_nil() &&
613618
!value_set_dereferencet::has_dereference(object))
614619
get_objects_rec(mode, object, range_start, new_size);
620+
else
621+
{
622+
// we don't have sufficient points-to information, dereferencing will yield
623+
// some in-memory object
624+
const symbolt &memory_symbol = ns.lookup(CPROVER_PREFIX "memory");
625+
get_objects_rec(mode, memory_symbol.symbol_expr(), -1, size);
626+
}
615627
}
616628

617629
void guarded_range_domaint::output(

0 commit comments

Comments
 (0)