Skip to content
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

Incorrectly failing assertion in program with goto statements #8437

Open
andreast271 opened this issue Sep 3, 2024 · 1 comment · May be fixed by #8439
Open

Incorrectly failing assertion in program with goto statements #8437

andreast271 opened this issue Sep 3, 2024 · 1 comment · May be fixed by #8439

Comments

@andreast271
Copy link
Contributor

The example file is attached:
gotos.c.txt

The failing assertion is line 15: assert(canary). On all valid execution paths, canary == 1, so the assertion should pass.

A look at the program equation shows the problem:

$cbmc --unwind 2 --unwinding-assertions gotos.c --program-only | grep canary
(11) canary!0@1#2 == 1
(14) canary!0@2#2 == 1
(18) ASSERT(!(canary!0@2#0 == 0))

The level 2 version of variable canary in the assertion is not the one in the program equation. At a guess the mechanism keeping track of scopes gets confused by the goto statements that is crossing scope boundaries.
Note: the example originated as an auto-generated C file created by Csmith.

CBMC version: 6.2.0
Operating system: Linux 64
Exact command line resulting in the issue: cbmc --unwind 2 --unwinding-assertions gotos.c
What behaviour did you expect: all assertions should pass
What happened instead: one assertion failed

tautschnig added a commit to tautschnig/cbmc that referenced this issue Sep 3, 2024
A local variable may have left the scope on a branch, but may still
exist via another path. Upon merging paths we must not lose such
objects.

Fixes: diffblue#8437
@tautschnig tautschnig linked a pull request Sep 3, 2024 that will close this issue
3 tasks
@tautschnig
Copy link
Collaborator

Thank you for the very helpful report! Proposed fix in #8439.

tautschnig added a commit to tautschnig/cbmc that referenced this issue Sep 5, 2024
A local variable may have left the scope on a branch, but may still
exist via another path. Upon merging paths we must not lose such
objects.

Fixes: diffblue#8437
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants