Skip to content

Add workaround for issue described in #6168. #6340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions regression/contracts/github_6168_infinite_unwinding_bug/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <assert.h>
#include <stdlib.h>

static int adder(const int *a, const int *b)
{
return (*a + *b);
}

int main()
{
int x = 1024;

int (*local_adder)(const int *, const int *) = adder;

while(x > 0)
__CPROVER_loop_invariant(1 == 1)
{
x += local_adder(&x, &x); // loop detection fails
//x += adder(&x, &x); // works fine
}
}
11 changes: 11 additions & 0 deletions regression/contracts/github_6168_infinite_unwinding_bug/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--apply-loop-contracts
^EXIT=0$
^SIGNAL=0$
^VERIFICATION SUCCESSFUL$
^\[main.1\] line \d+ Check loop invariant before entry: SUCCESS$
^\[main.2\] line \d+ Check that loop invariant is preserved: SUCCESS$
--
--
This is guarding against an issue described in https://github.com/diffblue/cbmc/issues/6168.
1 change: 1 addition & 0 deletions src/goto-instrument/goto_instrument_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,7 @@ void goto_instrument_parse_optionst::instrument_goto_program()
cmdline.isset(FLAG_ENFORCE_CONTRACT) ||
cmdline.isset(FLAG_ENFORCE_ALL_CONTRACTS))
{
do_indirect_call_and_rtti_removal();
code_contractst cont(goto_model, log);

if(cmdline.isset(FLAG_REPLACE_CALL))
Expand Down