Conversation
melver
requested review from
kroening,
peterschrammel and
tautschnig
as code owners
November 6, 2026 11:46
peterschrammel
approved these changes
Nov 6, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #9398 +/- ##
===========================================
- Coverage 81.02% 81.02% -0.01%
===========================================
Files 1723 1723
Lines 191314 191314
Branches 73 73
===========================================
- Hits 155020 155017 -3
- Misses 36294 36297 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Consider an inner loop that is entered by an unconditional forward goto:
int i = 0;
outer:;
int j = 0;
goto inner;
inner:
j++;
if(j < 3)
goto inner;
i++;
if(i < 2)
goto outer;
The inner loop runs 3 times per outer iteration, so --unwind 3 should
suffice. symex_transition resets a loop's unwinding counter when it
enters the loop, i.e., on a forward transition to the loop head, or on a
backward one from outside the loop. symex_goto, however, has a fast path
for unconditional gotos taken while the guard is true, which always
reported the transition as backward. A forward goto into the loop head
thus did not reset the counter, and the inner loop kept counting across
outer iterations. With --unwinding-assertions this reported a spurious
unwinding failure even at --unwind 4; without, unwinding stopped too
early. Entering the loop by fallthrough was not affected.
Backward gotos with a true condition return before reaching the fast
path, so it only sees forward gotos. Pass the actual direction of the
goto.
melver
force-pushed
the
fix-symex-forward-goto-loop-entry
branch
from
November 8, 2026 13:36
2e0d1e1 to
dc87b8c
Compare
Contributor
Author
|
Thanks for the review! I assume one of you needs to press "merge", because I do not have permissions? |
Member
|
Great find, @melver! |
tautschnig
added a commit
to tautschnig/cbmc
that referenced
this pull request
Nov 23, 2026
symex_goto takes its unconditional-goto fast path either when the state guard is true or when doing path exploration. The test added in diffblue#9398 only uses constants, so its guard is always true and it never exercises the second case. Add a variant where the guard at the forward goto into the inner loop's head is not true on the second outer iteration, and run it with --paths lifo. Without the fix from diffblue#9398 this test fails with a spurious unwinding-assertion failure for the inner loop. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
tautschnig
added a commit
to tautschnig/cbmc
that referenced
this pull request
Nov 23, 2026
With path exploration (--paths), symex_goto saves both successors of a branch. When the saved jump-target path of a backward goto is resumed, the two successors are swapped, so state_pc is the instruction following the goto rather than the goto's target. symex_goto nevertheless told symex_transition that this transition was a backward goto. If the next instruction is a loop head, symex_transition then only resets that loop's unwinding counter when arriving from beyond the loop's back edge, which never holds for an instruction preceding the loop. The counter thus kept counting across entries of the loop, yielding spurious unwinding-assertion failures (or unwinding stopped too early without --unwinding-assertions). This is the same mix-up of transition direction as was fixed for the unconditional-goto fast path in diffblue#9398. The transition to state_pc is backward only if state_pc is the target of a backward goto. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
tautschnig
added a commit
to tautschnig/cbmc
that referenced
this pull request
Nov 23, 2026
The three-argument overload of symex_transition had no documentation, yet its is_backwards_goto flag decides whether a transition onto a loop head resets that loop's unwinding counter. Passing the wrong value caused both the bug fixed in diffblue#9398 and the one fixed for resumed fall-through paths of backward gotos. Spell out which transitions count as backward. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
tautschnig
added a commit
to tautschnig/cbmc
that referenced
this pull request
Nov 23, 2026
With path exploration (--paths), symex_goto saves both successors of a branch. When the saved jump-target path of a backward goto is resumed, the two successors are swapped, so state_pc is the instruction following the goto rather than the goto's target. symex_goto nevertheless told symex_transition that this transition was a backward goto. If the next instruction is a loop head, symex_transition then only resets that loop's unwinding counter when arriving from beyond the loop's back edge, which never holds for an instruction preceding the loop. The counter thus kept counting across entries of the loop, yielding spurious unwinding-assertion failures (or unwinding stopped too early without --unwinding-assertions). This is the same mix-up of transition direction as was fixed for the unconditional-goto fast path in diffblue#9398. The transition to state_pc is backward only if state_pc is the target of a backward goto. The three-argument overload of symex_transition had no documentation, yet its is_backwards_goto flag decides whether a transition onto a loop head resets that loop's unwinding counter. Spell out which transitions count as backward. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
This was referenced Nov 23, 2026
kroening
pushed a commit
that referenced
this pull request
Nov 26, 2026
symex_goto takes its unconditional-goto fast path either when the state guard is true or when doing path exploration. The test added in #9398 only uses constants, so its guard is always true and it never exercises the second case. Add a variant where the guard at the forward goto into the inner loop's head is not true on the second outer iteration, and run it with --paths lifo. Without the fix from #9398 this test fails with a spurious unwinding-assertion failure for the inner loop. Co-authored-by: Kiro <kiro-agent@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Consider an inner loop that is entered by an unconditional forward goto:
The inner loop runs 3 times per outer iteration, so --unwind 3 should suffice. symex_transition resets a loop's unwinding counter when it enters the loop, i.e., on a forward transition to the loop head, or on a backward one from outside the loop. symex_goto, however, has a fast path for unconditional gotos taken while the guard is true, which always reported the transition as backward. A forward goto into the loop head thus did not reset the counter, and the inner loop kept counting across outer iterations. With --unwinding-assertions this reported a spurious unwinding failure even at --unwind 4; without, unwinding stopped too early. Entering the loop by fallthrough was not affected.
Backward gotos with a true condition return before reaching the fast path, so it only sees forward gotos. Pass the actual direction of the goto.
Assisted-by: Antigravity