Skip to content

Commit 864b6b2

Browse files
authored
Merge pull request #40 from tautschnig/mem-properties
Refine and extend reporting of memory safety errors
2 parents ff9a66e + 55a2a2b commit 864b6b2

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

tool-wrapper.inc

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ OPTIONS["unreach_call"]=""
1010
OPTIONS["termination"]=""
1111
OPTIONS["overflow"]="--signed-overflow-check --no-assertions"
1212
OPTIONS["memsafety"]="--pointer-check --memory-leak-check --bounds-check --no-assertions"
13+
OPTIONS["memcleanup"]="--pointer-check --memory-leak-check --bounds-check --no-assertions"
1314

1415
parse_property_file()
1516
{
@@ -22,6 +23,7 @@ if(/^CHECK\(init\((\S+)\(\)\),LTL\((\S+)\)\)$/) {
2223
print "PROP=\"unreach_call\"\n" if($2 =~ /^G!call\(__VERIFIER_error\(\)\)$/);
2324
print "PROP=\"unreach_call\"\n" if($2 =~ /^Gassert$/);
2425
print "PROP=\"memsafety\"\n" if($2 =~ /^Gvalid-(free|deref|memtrack)$/);
26+
print "PROP=\"memcleanup\"\n" if($2 =~ /^Gvalid-(free|deref|memtrack)$/);
2527
print "PROP=\"overflow\"\n" if($2 =~ /^G!overflow$/);
2628
print "PROP=\"termination\"\n" if($2 =~ /^Fend$/);
2729
}'
@@ -31,25 +33,44 @@ parse_result()
3133
{
3234
if tail -n 50 $LOG.ok | \
3335
grep -Eq "^(\[.*\] .*__CPROVER_memory_leak == NULL|[[:space:]]*__CPROVER_memory_leak == NULL$)" ; then
34-
echo 'FALSE(valid-memtrack)'
36+
if [[ "$PROP" == "memcleanup" ]]; then
37+
echo 'FALSE(valid-memcleanup)'
38+
else
39+
echo 'FALSE(valid-memtrack)'
40+
fi
3541
elif tail -n 50 $LOG.ok | \
3642
grep -Eq "^(\[.*\] |[[:space:]]*)dynamically allocated memory never freed in " ; then
37-
echo 'FALSE(valid-memtrack)'
43+
if [[ "$PROP" == "memcleanup" ]]; then
44+
echo 'FALSE(valid-memcleanup)'
45+
else
46+
echo 'FALSE(valid-memtrack)'
47+
fi
3848
elif tail -n 50 $LOG.ok | \
3949
grep -Eq "^(\[.*\] |[[:space:]]*)dereference failure:" ; then
4050
echo 'FALSE(valid-deref)'
4151
elif tail -n 50 $LOG.ok | \
4252
grep -Eq "^(\[.*\] |[[:space:]]*)array.* upper bound in " ; then
4353
echo 'FALSE(valid-deref)'
54+
elif tail -n 50 $LOG.ok | \
55+
grep -Eq "^[[:space:]]+mem(cpy|set|move) (source region readable|destination region writeable)" ; then
56+
echo 'FALSE(valid-deref)'
4457
elif tail -n 50 $LOG.ok | \
4558
grep -Eq "^(\[.*\] double free|[[:space:]]*double free$)" ; then
4659
echo 'FALSE(valid-free)'
4760
elif tail -n 50 $LOG.ok | \
4861
grep -Eq "^(\[.*\] free argument has offset zero|[[:space:]]* free argument has offset zero$)" ; then
49-
echo 'FALSE(valid-free)'
62+
if tail -n 50 $LOG.ok | grep -Eq "^[[:space:]]+[a-zA-Z0-9_]+=INVALID" ; then
63+
echo 'FALSE(valid-deref)'
64+
else
65+
echo 'FALSE(valid-free)'
66+
fi
5067
elif tail -n 50 $LOG.ok | \
5168
grep -Eq "^(\[.*\] |[[:space:]]*)free argument (is|must be) dynamic object" ; then
52-
echo 'FALSE(valid-free)'
69+
if tail -n 50 $LOG.ok | grep -Eq "^[[:space:]]+[a-zA-Z0-9_]+=INVALID" ; then
70+
echo 'FALSE(valid-deref)'
71+
else
72+
echo 'FALSE(valid-free)'
73+
fi
5374
elif tail -n 50 $LOG.ok | \
5475
grep -Eq "^(\[.*\] |[[:space:]]*)arithmetic overflow on signed" ; then
5576
echo 'FALSE(no-overflow)'

0 commit comments

Comments
 (0)