Skip to content

Commit 507d221

Browse files
Fix memory leak check for __VERIFIER_error
1 parent 6b33362 commit 507d221

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

regression/cbmc/Memory_leak_abort/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <stdlib.h>
22

3-
extern void __VERIFIER_error() __attribute__ ((__noreturn__));
3+
extern void __VERIFIER_error() __attribute__((__noreturn__));
44

55
int main()
66
{
@@ -11,6 +11,8 @@ int main()
1111
exit(1);
1212
if(*p == 2)
1313
_Exit(1);
14+
if(*p == 3)
15+
__VERIFIER_error();
1416
free(p);
1517
return 0;
1618
}
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)