File tree 30 files changed +360
-1
lines changed
r_w_ok_inconsistent_deallocated
r_w_ok_inconsistent_integer
r_w_ok_inconsistent_invalid
r_w_ok_inconsistent_nondet 30 files changed +360
-1
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ add_subdirectory(goto-cc-file-local)
56
56
add_subdirectory (linking-goto-binaries)
57
57
add_subdirectory (symtab2gb)
58
58
add_subdirectory (validate-trace-xml-schema)
59
+ add_subdirectory (cbmc-primitives)
59
60
60
61
if (WITH_MEMORY_ANALYZER)
61
62
add_subdirectory (snapshot-harness)
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ DIRS = cbmc \
33
33
solver-hardness \
34
34
goto-ld \
35
35
validate-trace-xml-schema \
36
- # Empty last line
36
+ cbmc-primitives \
37
+ # Empty last line
37
38
38
39
ifeq ($(OS ) ,Windows_NT)
39
40
detected_OS := Windows
Original file line number Diff line number Diff line change
1
+ add_test_pl_tests(
2
+ "$<TARGET_FILE:cbmc>"
3
+ )
Original file line number Diff line number Diff line change
1
+ default : tests.log
2
+
3
+ test :
4
+ @../test.pl -e -p -c ../../../src/cbmc/cbmc
5
+
6
+ tests.log : ../test.pl
7
+ @../test.pl -e -p -c ../../../src/cbmc/cbmc
8
+
9
+ show :
10
+ @for dir in * ; do \
11
+ if [ -d " $$ dir" ]; then \
12
+ vim -o " $$ dir/*.c" " $$ dir/*.out" ; \
13
+ fi ; \
14
+ done ;
15
+
16
+ clean :
17
+ find -name ' *.out' -execdir $(RM ) ' {}' \;
18
+ $(RM ) tests.log
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ void main ()
5
+ {
6
+ char * p1 ;
7
+ __CPROVER_assume (__CPROVER_r_ok (p1 - 1 , 1 ));
8
+ * p1 ;
9
+ }
Original file line number Diff line number Diff line change
1
+ KNOWNBUG
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ --
7
+ ^warning: ignoring
8
+ --
9
+ Crashes during the flattening, issue #5328
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ void main ()
5
+ {
6
+ char * p ;
7
+
8
+ {
9
+ char c ;
10
+ p = & c ;
11
+ }
12
+
13
+ __CPROVER_assume (__CPROVER_r_ok (p , 1 ));
14
+ assert (0 ); // fails
15
+ * p ; // succeeds
16
+ }
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a pointer to an out of scope
11
+ variable and __CPROVER_r_ok() can be detected via assert(0). We use
12
+ --no-simplify and --no-propagation to ensure that the case is not solved by the
13
+ constant propagation and thus tests the constraint encoding.
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --function test_global_pointer --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a pointer to an out of scope
11
+ variable and __CPROVER_r_ok() can be detected via assert(0).
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ void main ()
5
+ {
6
+ char * p = malloc (1 );
7
+ free (p );
8
+
9
+ __CPROVER_assume (__CPROVER_r_ok (p , 1 ));
10
+ assert (0 ); // fails
11
+ * p ; // succeeds
12
+ }
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a pointer initialized to an
11
+ integer address not pointing to memory and __CPROVER_r_ok() can be detected via
12
+ assert(0). We use --no-simplify and --no-propagation to ensure that the case is
13
+ not solved by the constant propagation and thus tests the constraint encoding.
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a pointer initialized to an
11
+ integer address not pointing to memory and __CPROVER_r_ok() can be detected via
12
+ assert(0).
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ void main ()
5
+ {
6
+ // pointer with object bits = 123 and offset = 123
7
+ // this is to test with a pointer that does not point to valid memory, but the
8
+ // value of which is otherwise not special in any way (like for example a null
9
+ // pointer)
10
+ char * p = (size_t )123 << (sizeof (char * ) * 8 - 8 ) | 123 ;
11
+ __CPROVER_assume (__CPROVER_r_ok (p , 10 ));
12
+ assert (0 ); // fails
13
+ * p ; // succeeds
14
+ }
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a pointer initialized to an
11
+ integer address not pointing to memory and __CPROVER_r_ok() can be detected via
12
+ assert(0). We use --no-simplify and --no-propagation to ensure that the case is
13
+ not solved by the constant propagation and thus tests the constraint encoding.
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a pointer initialized to an
11
+ integer address not pointing to memory and __CPROVER_r_ok() can be detected via
12
+ assert(0).
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ void main ()
5
+ {
6
+ // special value of the invalid pointer (object bits = 1 and offset = 0), as
7
+ // checked for by __CPROVER_is_invalid_pointer()
8
+ char * p = (size_t )1 << (sizeof (char * ) * 8 - 8 );
9
+ __CPROVER_assume (__CPROVER_r_ok (p , 10 ));
10
+ assert (0 ); // fails
11
+ * p ; // succeeds
12
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving the special invalid pointer
11
+ value and __CPROVER_r_ok() can be detected via assert(0). We use --no-simplify
12
+ and --no-propagation to ensure that the case is not solved by the constant
13
+ propagation and thus tests the constraint encoding.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving the special invalid pointer
11
+ value and __CPROVER_r_ok() can be detected via assert(0).
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+
3
+ char * nondet ();
4
+
5
+ void main ()
6
+ {
7
+ char * p = nondet ();
8
+ __CPROVER_assume (__CPROVER_r_ok (p , 10 ));
9
+ assert (0 ); // fails
10
+ * p ; // succeeds
11
+ }
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a nondet pointer and
11
+ __CPROVER_r_ok() can be detected via assert(0). We use --no-simplify and
12
+ --no-propagation to ensure that the case is not solved by the constant
13
+ propagation and thus tests the constraint encoding.
Original file line number Diff line number Diff line change
1
+ FUTURE
2
+ main.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that an inconsistent assumption involving a nondet pointer and
11
+ __CPROVER_r_ok() can be detected via assert(0).
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ void main ()
5
+ {
6
+ char * p = NULL ;
7
+ assert (!__CPROVER_r_ok (p , 10 ));
8
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that __CPROVER_r_ok() on a null pointers is false. We use --no-simplify
11
+ and --no-propagation to ensure that the case is not solved by the constant
12
+ propagation and thus tests the constraint encoding.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that __CPROVER_r_ok() on a null pointers is false
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ char c1 ;
5
+
6
+ void main ()
7
+ {
8
+ char c2 ;
9
+
10
+ char * p1 = & c1 ;
11
+ assert (__CPROVER_r_ok (p1 , 1 ));
12
+
13
+ char * p2 = & c2 ;
14
+ assert (__CPROVER_r_ok (p2 , 1 ));
15
+
16
+ char * p3 = malloc (1 );
17
+ __CPROVER_assume (p1 != NULL );
18
+ assert (__CPROVER_r_ok (p3 , 1 ));
19
+ }
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that __CPROVER_r_ok() is true for valid pointers to global, local, or
11
+ malloced memory. We use --no-simplify and --no-propagation to ensure that the
12
+ case is not solved by the constant propagation and thus tests the constraint
13
+ encoding.
Original file line number Diff line number Diff line change
1
+ CORE
2
+ main.c
3
+ --pointer-check
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that __CPROVER_r_ok() is true for valid pointers to global, local, or
11
+ malloced memory
Original file line number Diff line number Diff line change
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ char c1 ;
5
+
6
+ void main ()
7
+ {
8
+ // We check the conditions for a pointer to global static memory (p1), a
9
+ // pointer to local memory (p2), and a pointer to dynamic memory (p3).
10
+ // For each pointer, we check:
11
+ // (1) whether it is unsafe to access one byte more than was allocated
12
+ // (2) whether it is unsafe to access one byte before the allocated memory
13
+ // (3) whether it is unsafe to access one byte after the allocated memory
14
+
15
+ char c2 ;
16
+
17
+ char * p1 = & c1 ;
18
+
19
+ assert (!__CPROVER_r_ok (p1 , 2 ));
20
+ assert (!__CPROVER_r_ok (p1 - 1 , 1 ));
21
+ assert (!__CPROVER_r_ok (p1 + 1 , 1 ));
22
+
23
+ char * p2 = & c2 ;
24
+
25
+ assert (!__CPROVER_r_ok (p2 , 2 ));
26
+ assert (!__CPROVER_r_ok (p2 - 1 , 1 ));
27
+ assert (!__CPROVER_r_ok (p2 + 1 , 1 ));
28
+
29
+ char * p3 = malloc (1 );
30
+
31
+ assert (!__CPROVER_r_ok (p3 , 2 ));
32
+ assert (!__CPROVER_r_ok (p3 - 1 , 1 ));
33
+ assert (!__CPROVER_r_ok (p3 + 1 , 1 ));
34
+ }
Original file line number Diff line number Diff line change
1
+ KNOWNBUG
2
+ main.c
3
+ --pointer-check --no-simplify --no-propagation
4
+ ^EXIT=0$
5
+ ^SIGNAL=0$
6
+ ^VERIFICATION SUCCESSFUL$
7
+ --
8
+ ^warning: ignoring
9
+ --
10
+ Tests that __CPROVER_r_ok() is false for a pointer to a valid memory object,
11
+ though potentially with an offset that is out of bounds. We use --no-simplify
12
+ and --no-propagation to ensure that the case is not solved by the constant
13
+ propagation and thus tests the constraint encoding.
You can’t perform that action at this time.
0 commit comments