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

SMTChecker: Loop is unrolled after it completes #14447

Closed
pgebal opened this issue Jul 25, 2023 · 3 comments · Fixed by #14448
Closed

SMTChecker: Loop is unrolled after it completes #14447

pgebal opened this issue Jul 25, 2023 · 3 comments · Fixed by #14448
Assignees

Comments

@pgebal
Copy link
Collaborator

pgebal commented Jul 25, 2023

Description

For some cases model checker unrolls a loop even after it should complete.

Environment

Steps to Reproduce

run compiler with --model-checker-engine bmc --model-checker-bmc-loop-iterations 5 --model-checker-solvers z3 on the following contract:

// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.0;
contract C
{
	uint x;
	uint y;

	function condition() private returns(bool) {
		x = (x + 1) % 2;
		return (x == 1);
	}

	function f() public {
		require(x == 0);
		require(y == 0);
		for (; condition();) {
			++y;
		}
		assert(y == 1);
	}
}

I expect the assertion y == 1 to hold but it fails, y > 1 holds and it shouldn't.
There is a similar bug in while and do while loops.

@agnxsh
Copy link

agnxsh commented Jul 25, 2023

hi can anyone assign me this? I can look into it!

@pgebal pgebal self-assigned this Jul 25, 2023
@pgebal
Copy link
Collaborator Author

pgebal commented Jul 25, 2023

hi can anyone assign me this? I can look into it!

Hi @agnxsh. There is already a PR fixing this: #14448

@pgebal pgebal changed the title SMT checker: Loop is unrolled after it completes SMTChecker: Loop is unrolled after it completes Jul 25, 2023
@agnxsh
Copy link

agnxsh commented Jul 26, 2023

sure

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