Skip to content

Commit 2006bef

Browse files
authored
Merge pull request #5823 from tautschnig/pointer-encoding-tests
Tests demonstrating pointer-encoding unsoundness
2 parents 8370c47 + e5e8239 commit 2006bef

File tree

4 files changed

+49
-0
lines changed

4 files changed

+49
-0
lines changed
Lines changed: 11 additions & 0 deletions
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+
{
7+
char *base = BASE;
8+
int offset = OFFSET;
9+
__CPROVER_assert(
10+
&((char *)base)[offset] >= BASE + OFFSET, "no wrap-around expected");
11+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
main.c
3+
--32
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
--
8+
^warning: ignoring
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
if(
13+
(unsigned long)p >
14+
42) // unsoundly evaluates to true due to pointer encoding
15+
{
16+
return 0;
17+
}
18+
19+
__CPROVER_assert(0, "");
20+
21+
return 0;
22+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
KNOWNBUG
2+
main.c
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
--
8+
^warning: ignoring

0 commit comments

Comments
 (0)