Skip to content

Reset loop counter when resuming fall-through of a backward goto - #9563

Open
tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:post-merge-fixups-9398
Open

tautschnig wants to merge 1 commit into
diffblue:developfrom
tautschnig:post-merge-fixups-9398

Conversation

@tautschnig

Copy link
Copy Markdown
Collaborator

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 #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.

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

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>
Copilot AI balanced review requested due to automatic review settings November 23, 2026 11:55

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.27%. Comparing base (11135d7) to head (9a5eec7).
⚠️ Report is 4 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #9563      +/-   ##
===========================================
- Coverage    81.28%   81.27%   -0.01%     
===========================================
  Files         1725     1725              
  Lines       191618   191619       +1     
  Branches        73       73              
===========================================
- Hits        155751   155747       -4     
- Misses       35867    35872       +5     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants