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

Warn users when annotations may add inifinte loops #38

Open
cd1m0 opened this issue Apr 23, 2021 · 1 comment
Open

Warn users when annotations may add inifinte loops #38

cd1m0 opened this issue Apr 23, 2021 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@cd1m0
Copy link
Collaborator

cd1m0 commented Apr 23, 2021

Instrumentation turns the following terminating code into non-terminating code:

contract Foo {
        function double1(uint x) public view returns (uint) {
                return double2(x);
        }

        /// if_succeeds $result == double1(x);
        function double2(uint x) public view returns (uint) {
                return x + x;
        }
}

We can use the callgraph of the original code to detect when function calls in the annotations may create cycles and issue warnings for users that the annotations may introduce infinite recursion. For example this check shouldn't flag anything in the following sample:

contract Foo {
        /// if_succeeds $result == double2(x);
        function double1(uint x) public view returns (uint) {
                return x * 2;
        }       

        /// if_succeeds $result == double1(x);
        function double2(uint x) public view returns (uint) {
                return x + x;
        }       
}
@cd1m0 cd1m0 self-assigned this Apr 23, 2021
@cd1m0 cd1m0 added the enhancement New feature or request label Nov 18, 2021
@blitz-1306
Copy link
Contributor

blitz-1306 commented Jun 5, 2023

This is not straightforward, as sometimes we can encounder conditional constructs in annotations and in functions. Therefore, in case of naive implementation some produced warnings might be misleading.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants