Skip to content

Commit 037e860

Browse files
authored
Merge pull request #5212 from xbauch/feature/malloc-may-fail
Add malloc-may-fail option to goto-check
2 parents 7405bfb + d49cfdd commit 037e860

File tree

22 files changed

+120
-48
lines changed

22 files changed

+120
-48
lines changed

doc/cprover-manual/properties.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ with `__`.
326326
|------------------------|-------------------------------------------------|
327327
| `--malloc-fail-null` | in case malloc fails return NULL |
328328
| `--malloc-fail-assert` | in case malloc fails report as failed property |
329+
| `--malloc-may-fail` | malloc may non-deterministically fail |
329330

330331
Calling `malloc` may fail for a number of reasons and the function may return a
331332
NULL pointer. The users can choose if and how they want the `malloc`-related
@@ -335,3 +336,7 @@ additional properties inside `malloc` that are checked and if failing the
335336
verification is terminated (by `assume(false)`). One such property is that the
336337
allocated size is not too large, i.e. internally representable. When neither of
337338
those two options are used, CBMC will assume that `malloc` does not fail.
339+
340+
Malloc may also fail for external reasons which are not modelled by CProver. If
341+
you want to replicate this behaviour use the option `--malloc-may-fail` in
342+
conjunction with one of the above modes of failure.

regression/cbmc/Pointer_byte_extract5/no-simplify.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ main.i
44
^EXIT=10$
55
^SIGNAL=0$
66
array\.List dynamic object upper bound in p->List\[2\]: FAILURE
7-
\*\* 1 of 15 failed
7+
\*\* 1 of 16 failed
88
--
99
^warning: ignoring
1010
--

regression/cbmc/Pointer_byte_extract5/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ main.i
44
^EXIT=10$
55
^SIGNAL=0$
66
array\.List dynamic object upper bound in p->List\[2\]: FAILURE
7-
\*\* 1 of 13 failed
7+
\*\* 1 of 14 failed
88
--
99
^warning: ignoring
1010
--

regression/cbmc/array_constraints1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ main.c
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
7-
^\*\* 2 of 15
7+
^\*\* 2 of 16
88
--
99
^warning: ignoring
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include <stdlib.h>
2+
3+
int main()
4+
{
5+
char *p = malloc(100);
6+
assert(p); // should fail, given the malloc-may-fail option
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--malloc-may-fail --malloc-fail-null
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main.assertion.\d+\] line \d+ assertion p: FAILURE$
7+
^VERIFICATION FAILED$
8+
--
9+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main.assertion.\d+\] line \d+ assertion p: SUCCESS$
7+
^VERIFICATION SUCCESSFUL$
8+
--
9+
^warning: ignoring

regression/cbmc/pointer-overflow1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ main.c
55
^SIGNAL=0$
66
^\[main\.overflow\.\d+\] line \d+ (pointer )?arithmetic overflow on .*sizeof\(signed int\) .* : SUCCESS
77
^VERIFICATION FAILED$
8-
^\*\* 8 of 12 failed
8+
^\*\* 8 of 13 failed
99
--
1010
^\[main\.overflow\.\d+\] line \d+ (pointer )?arithmetic overflow on .*sizeof\(signed int\) .* : FAILURE
1111
^warning: ignoring

regression/cbmc/r_w_ok1/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CORE
22
main.c
33

44
__CPROVER_[rw]_ok\(arbitrary_size, n \+ 1\): FAILURE$
5-
^\*\* 2 of 11 failed
5+
^\*\* 2 of 12 failed
66
^VERIFICATION FAILED$
77
^EXIT=10$
88
^SIGNAL=0$

regression/goto-analyzer/constant_propagation_01/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ main.c
33
--constants --simplify out.gb
44
^EXIT=0$
55
^SIGNAL=0$
6-
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 7, function calls: 0$
6+
^Simplified: assert: 1, assume: 0, goto: 1, assigns: 8, function calls: 0$
77
^Unmodified: assert: 0, assume: 0, goto: 0, assigns: 18, function calls: 2$
88
--
99
^warning: ignoring

0 commit comments

Comments
 (0)