Skip to content

Loop counter resetting must not result in unlimited unwinding #5870

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 1 commit into from
Feb 26, 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
24 changes: 24 additions & 0 deletions regression/cbmc/unwind_counters4/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
int main()
{
int x;
int y;

do
{
y = 10;
goto label;
x = 1; // dead code, makes sure the above goto is not removed
label:
_Bool nondet;
if(nondet)
__CPROVER_assert(y != 10, "violated via first loop");
else
__CPROVER_assert(y != 20, "violated via second loop");

if(x % 2)
break; // this statement must not cause the loop counter to be reset
} while(1);

y = 20;
goto label;
}
11 changes: 11 additions & 0 deletions regression/cbmc/unwind_counters4/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
main.c
--unwind 2
^EXIT=10$
^SIGNAL=0$
^VERIFICATION FAILED$
^\** 2 of 2 failed
--
--
Loop unwinding must terminate despite the existence of multiple loop entry
points.
2 changes: 1 addition & 1 deletion src/goto-symex/symex_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ void symex_transition(
for(const auto &i_e : instruction.incoming_edges)
{
if(
i_e->is_goto() && i_e->is_backwards_goto() &&
i_e->is_backwards_goto() && i_e->get_target() == to &&
(!is_backwards_goto ||
state.source.pc->location_number > i_e->location_number))
{
Expand Down