Skip to content

Commit 1a4ee91

Browse files
thomasspriggsNlightNFotis
authored andcommitted
Add tests of memory checks inside existential qualifiers
1 parent 7a57025 commit 1a4ee91

File tree

8 files changed

+100
-0
lines changed

8 files changed

+100
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int *a = calloc(10, sizeof(int));
7+
a[5] = 25;
8+
9+
assert(__CPROVER_exists {
10+
int i;
11+
(0 <= i && i < 20) && a[i] == i *i
12+
});
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
invalid_index_range.c
3+
--pointer-check
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
line 9 dereference failure: pointer outside object bounds in a\[\(signed long int\)i\]: FAILURE
8+
--
9+
--
10+
Check that memory checks fail for pointer dereferences inside an existential
11+
qualifier, for out of bounds memory access.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int *a = calloc(10, sizeof(int));
7+
a[5] = 25;
8+
9+
assert(!__CPROVER_exists {
10+
int i;
11+
(0 <= i && i < 10) && a[i] == 42
12+
});
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
valid_index_range.c
3+
--pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
line 9 dereference failure:.*SUCCESS
8+
--
9+
--
10+
Check that memory checks pass for valid pointer dereferences inside a negated
11+
existential qualifier.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int *a = calloc(10, sizeof(int));
7+
a[5] = 25;
8+
9+
assert(__CPROVER_exists {
10+
int i;
11+
a[i] == i *i
12+
});
13+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
smt_missing_range_check.c
3+
--pointer-check -z3
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^VERIFICATION FAILED$
7+
\[main\.assertion\.1\] line \d assertion __CPROVER_exists \{ int i; a\[i\] == i \*i \}: SUCCESS
8+
\[main\.pointer_dereference\.11\] line \d dereference failure: pointer outside object bounds in a\[\(signed long int\)i\]: FAILURE
9+
--
10+
--
11+
Check that memory checks fail for pointer dereferences inside an existential
12+
qualifier, for out of bounds memory access, when using the smt backend and
13+
the range of the index is unbound. Note that this test is not expected to work
14+
with the SAT backend at the time of writing, as the SAT backend does not support
15+
qualifiers in this form.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <assert.h>
2+
#include <stdlib.h>
3+
4+
int main()
5+
{
6+
int *a = calloc(10, sizeof(int));
7+
a[5] = 25;
8+
9+
assert(__CPROVER_exists {
10+
int i;
11+
(0 <= i && i < 10) && a[i] == i *i
12+
});
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE
2+
valid_index_range.c
3+
--pointer-check
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^VERIFICATION SUCCESSFUL$
7+
line 9 dereference failure:.*SUCCESS
8+
--
9+
--
10+
Check that memory checks pass for valid pointer dereferences inside an
11+
existential qualifier.

0 commit comments

Comments
 (0)