Skip to content

Commit 7ad5757

Browse files
committed
pointer checks are now fatal
The checks for * pointer dereferences * pointer relations * pointer arithmetic are designed to identify cases of undefined behavior. They must be fatal.
1 parent 621fe05 commit 7ad5757

File tree

13 files changed

+22
-17
lines changed

13 files changed

+22
-17
lines changed

regression/cbmc/Function_Pointer18/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
3+
--no-pointer-check
44
^EXIT=10$
55
^SIGNAL=0$
66
\[f2.assertion.1\] line [0-9]+ assertion 0: SUCCESS

regression/cbmc/Function_Pointer_Init_One_Candidate/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--function foo
3+
--function foo --no-pointer-check
44
^\[foo.assertion.\d+\] line \d+ assertion other_function\(4\) == 5: FAILURE$
55
^\[foo.assertion.\d+\] line \d+ assertion other_function\(4\) == 4: SUCCESS$
66
^EXIT=10$

regression/cbmc/Function_Pointer_Init_Two_Candidates/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
main.c
3-
--function foo
3+
--function foo --no-pointer-check
44
^\[foo.assertion.\d+\] line \d+ assertion other_function\(4\) == 5: FAILURE$
55
^\[foo.assertion.\d+\] line \d+ assertion other_function\(4\) >= 4: SUCCESS$
66
^EXIT=10$

regression/cbmc/array-cell-sensitivity10/test_execution.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
3+
--no-pointer-check
44
^VERIFICATION FAILED$
55
^\[main.assertion\.1\] line 16.*SUCCESS$
66
^\[main.assertion\.2\] line 17.*FAILURE$

regression/cbmc/array-cell-sensitivity3/test_execution.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
3+
--no-pointer-check
44
^VERIFICATION FAILED$
55
^\[main.assertion\.1\] line 9.*SUCCESS$
66
^\[main.assertion\.2\] line 10.*FAILURE$

regression/cbmc/array-cell-sensitivity7/test_execution.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
3+
--no-pointer-check
44
^VERIFICATION FAILED$
55
^\[main.assertion\.1\] line 10.*SUCCESS$
66
^\[main.assertion\.2\] line 11.*FAILURE$

regression/cbmc/array-cell-sensitivity8/test_execution.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
3+
--no-pointer-check
44
^VERIFICATION FAILED$
55
^\[main.assertion\.1\] line 11.*SUCCESS$
66
^\[main.assertion\.2\] line 12.*FAILURE$

regression/cbmc/byte_update14/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
test.c
3-
3+
--no-pointer-check
44
^VERIFICATION FAILED$
55
^\[main.assertion\.1\] line 10.*SUCCESS$
66
^\[main.assertion\.2\] line 11.*FAILURE$

regression/cbmc/memory_allocation1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ main.c
66
^\[main\.pointer_dereference\.2\] .* dereference failure: invalid integer address in \*p: SUCCESS$
77
^\[main\.assertion\.1\] .* assertion \*p==42: SUCCESS$
88
^\[main\.pointer_dereference\.[0-9]+\] .* dereference failure: invalid integer address in p\[.*1\]: FAILURE$
9-
^\[main\.assertion\.2\] .* assertion \*\(p\+1\)==42: SUCCESS$
9+
^\[main\.assertion\.2\] .* assertion \*\(p\+1\)==42: UNKNOWN$
1010
^VERIFICATION FAILED$
1111
--
1212
^warning: ignoring

regression/cbmc/pointer-extra-checks/main.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
1+
int nondet_int();
2+
13
int main()
24
{
5+
int i = nondet_int();
6+
7+
if(i == 0)
38
{
49
int *p = 0x0;
510

611
// Since local_bitvector_analysis can tell that p is NULL, this should
712
// generate only a NULL check, and not any of the other pointer checks.
813
*p = 1;
914
}
10-
15+
else if(i == 1)
1116
{
1217
int i;
1318
int *q = &i;
1419

1520
// This should only generate a not-dead check and a bounds-check.
1621
*q = 2;
1722
}
18-
23+
else if(i == 2)
1924
{
2025
int *r = __CPROVER_allocate(sizeof(int), 1);
2126

2227
// This should generate a not-deallocated check and a bounds-check.
2328
*r = 5;
2429
}
25-
30+
else if(i == 3)
2631
{
2732
int *s;
2833

regression/cbmc/ptr_arithmetic_on_null/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE gcc-only
22
main.c
3-
3+
--no-pointer-check
44
^\[main.assertion.1\] line .* assertion \(\(char \*\)NULL\) != \(char \*\)\(void \*\)0 \+ (\(.*\))?1: SUCCESS$
55
^\[main.assertion.2\] line .* assertion \(\(char \*\)NULL\) != \(char \*\)\(void \*\)0 - (\(.*\))?1: SUCCESS$
66
^\[main.assertion.3\] line .* assertion \(\(char \*\)NULL\) != \(char \*\)\(void \*\)0 \+ \(.*\)offset: SUCCESS$

regression/cbmc/switch8/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ main.c
88
^\[main\.pointer_dereference\.1\] line 36 dereference failure: dead object in \*p: SUCCESS$
99
^\[main\.pointer_dereference\.2\] line 36 dereference failure: pointer outside object bounds in \*p: SUCCESS$
1010
^\[main\.assertion\.3\] line 42 assertion \*p == 42: FAILURE$
11-
^\[main\.pointer_dereference\.5\] line 42 dereference failure: pointer outside object bounds in \*p: SUCCESS$
11+
^\[main\.pointer_dereference\.5\] line 42 dereference failure: pointer outside object bounds in \*p: UNKNOWN$
1212
^\[main\.pointer_dereference\.3\] line 42 dereference failure: pointer NULL in \*p: SUCCESS$
1313
^\[main\.pointer_dereference\.4\] line 42 dereference failure: dead object in \*p: FAILURE$
1414
^\[main\.assertion\.4\] line 49 assertion e == 42: FAILURE$

src/ansi-c/goto-conversion/goto_check_c.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ void goto_check_ct::pointer_rel_check(
13681368
c.assertion,
13691369
"pointer relation: " + c.description,
13701370
"pointer arithmetic",
1371-
false, // fatal
1371+
true, // fatal
13721372
expr.find_source_location(),
13731373
pointer,
13741374
guard);
@@ -1427,7 +1427,7 @@ void goto_check_ct::pointer_overflow_check(
14271427
c.assertion,
14281428
"pointer arithmetic: " + c.description,
14291429
"pointer arithmetic",
1430-
false, // fatal
1430+
true, // fatal
14311431
expr.find_source_location(),
14321432
expr,
14331433
guard);
@@ -1469,7 +1469,7 @@ void goto_check_ct::pointer_validity_check(
14691469
c.assertion,
14701470
"dereference failure: " + c.description,
14711471
"pointer dereference",
1472-
false, // fatal
1472+
true, // fatal
14731473
src_expr.find_source_location(),
14741474
src_expr,
14751475
guard);

0 commit comments

Comments
 (0)