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

Incorrect SSA for indirect call to function modifying global state #434

Open
aaronyoo opened this issue Apr 9, 2020 · 0 comments
Open
Labels
bug Something isn't working ir

Comments

@aaronyoo
Copy link

aaronyoo commented Apr 9, 2020

SSA doesn't track global state modification through indirect call. Consider the following two test cases, one performs the correct behavior but the other doesn't. I have attached screenshots of the resulting SSA IR in graph form

Correct:

pragma solidity >=0.4.16 <0.7.0;
contract Contract {
    int public a;
    function f() public {
        e();
        a += 1;
    }

    function e() public {
        a -= 1;
    }
}

correct

Incorrect:

pragma solidity >=0.4.16 <0.7.0;
pragma solidity >=0.4.16 <0.7.0;
contract Contract {
    int public a;
    function f() public {
        g();
        a += 1;
    }

    function e() public {
        a -= 1;
    }

    function g() public {
        e();
    }
}

image


The correct version uses a phi node to track the alteration to global state through the function call. However, when we add one more layer of indirection, it no longer tracks that alteration.

@montyly montyly added the bug Something isn't working label Apr 17, 2020
hbrodin added a commit that referenced this issue Mar 17, 2022
@0xalpharush 0xalpharush added the ir label Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ir
Projects
None yet
Development

No branches or pull requests

3 participants