Skip to content

Commit 84fff90

Browse files
Fix memory leak check for __VERIFIER_error
1 parent de6b2e5 commit 84fff90

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

regression/cbmc/Memory_leak_abort/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ int main() {
1010
exit(1);
1111
if(*p == 2)
1212
_Exit(1);
13+
if(*p == 3)
14+
__VERIFIER_error();
1315
free(p);
1416
return 0;
1517
}
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
CORE
22
main.c
3-
--memory-leak-check
3+
--memory-leak-check --no-assertions
44
^EXIT=10$
55
^SIGNAL=0$
66
^VERIFICATION FAILED$
77
_Exit\.memory-leak\.1.*FAILURE
88
__CPROVER__start\.memory-leak\.1.*SUCCESS
99
abort\.memory-leak\.1.*FAILURE
1010
exit\.memory-leak\.1.*FAILURE
11+
main\.memory-leak\.1.*FAILURE
1112
--
13+
main\.assertion\.1.*FAILURE
1214
^warning: ignoring

src/analyses/goto_check.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,8 @@ void goto_checkt::goto_check(
17081708
if(
17091709
enable_memory_leak_check && simplified_guard.is_false() &&
17101710
(i.function == "abort" || i.function == "exit" ||
1711-
i.function == "_Exit"))
1711+
i.function == "_Exit" ||
1712+
(i.labels.size() == 1 && i.labels.front() == "__VERIFIER_abort")))
17121713
{
17131714
memory_leak_check(i.function);
17141715
}

src/goto-programs/builtin_functions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,7 @@ void goto_convertt::do_function_call_symbol(
711711
// are being checked
712712
goto_programt::targett a=dest.add_instruction(ASSUME);
713713
a->guard=false_exprt();
714+
a->labels.push_back("__VERIFIER_abort");
714715
a->source_location=function.source_location();
715716
a->source_location.set("user-provided", true);
716717
}

0 commit comments

Comments
 (0)