Skip to content

Commit dbdffff

Browse files
committed
Encode integer addresses together with pointer object/offset
Instead of encoding pointers with the same bit width a pointer on a given platform has, just widen the bit-blasted encoding to include both the previous object/offset encoding as well as an (integer) address. The encoding is thus also trivially extended to handle larger numbers of objects and offsets of the same width as the address. Furthermore clean up the code to encapsulate encoding properly, and make in-code layout of pointer encoding more natural (it's now object, offset, integer-address). Fixes: diffblue#436 Fixes: diffblue#311 Fixes: diffblue#94
1 parent 804dce0 commit dbdffff

File tree

13 files changed

+568
-143
lines changed

13 files changed

+568
-143
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
CORE
1+
THOROUGH
22
main.c
33
--32 --little-endian
44
^EXIT=0$
55
^SIGNAL=0$
66
^VERIFICATION SUCCESSFUL$
77
--
88
^warning: ignoring
9+
--
10+
Takes around 2 minutes to run.

regression/cbmc/Pointer_Arithmetic13/test.desc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33

44
^EXIT=0$
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#define MB 0x00100000
2+
#define BASE (15*MB)
3+
#define OFFSET ( 1*MB)
4+
5+
main() {
6+
char val[4];
7+
char *base = BASE;
8+
int offset = OFFSET;
9+
int n = 2;
10+
__CPROVER_assert(&((char*)base)[offset]!=0, "no wrap-around expected");
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
--32
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdlib.h>
2+
3+
int main()
4+
{
5+
if(sizeof(void*)!=8)
6+
return 0;
7+
8+
char* p=malloc(1);
9+
if(p==0)
10+
return 0;
11+
12+
unsigned long x=0xFFFFFFFF;
13+
if((unsigned long)p > x) // unsoundly evaluates to true due to pointer encoding
14+
return 0;
15+
16+
__CPROVER_assert(0, "");
17+
18+
return 0;
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring

regression/cbmc/address_space_size_limit1/test.c

-16
This file was deleted.

regression/cbmc/address_space_size_limit1/test.desc

-7
This file was deleted.

src/solvers/flattening/boolbv_width.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ const boolbv_widtht::entryt &boolbv_widtht::get_entry(const typet &type) const
194194
// no width
195195
}
196196
else if(type_id==ID_pointer)
197-
entry.total_width = type_checked_cast<pointer_typet>(type).get_width();
197+
{
198+
entry.total_width = 3 * type_checked_cast<pointer_typet>(type).get_width();
199+
DATA_INVARIANT(entry.total_width != 0, "pointer must have width");
200+
}
198201
else if(type_id==ID_symbol)
199202
entry=get_entry(ns.follow(type));
200203
else if(type_id==ID_struct_tag)

0 commit comments

Comments
 (0)