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

[Codegen] Potential stack corruption? #14072

Closed
bshastry opened this issue Mar 27, 2023 · 2 comments
Closed

[Codegen] Potential stack corruption? #14072

bshastry opened this issue Mar 27, 2023 · 2 comments
Labels
Projects

Comments

@bshastry
Copy link
Contributor

contract C {
  bytes30 s = 0;
  function f(int i) public {
    payable(this).transfer(0);
  }
  receive() external payable {
    s;
    bytes30 l;
    assert(l == s);
  }
}
// ----
// f(int256): 0 ->

reverts without optimization only. With optimization it passes

Repro

$ cp test.sol test/libsolidity/semanticTests
$ isoltest -t semanticTests/test
@bshastry bshastry added this to Triage in Solidity via automation Mar 27, 2023
@bshastry
Copy link
Contributor Author

bshastry commented Mar 27, 2023

It looks like an assertion failure but a panic code (https://docs.soliditylang.org/en/latest/control-structures.html#panic-via-assert-and-error-via-require) is not emitted. transfer may be reverting and not propagating the panic due to failed assertion.

@bshastry
Copy link
Contributor Author

Closing because @chriseth strongly feels this has to do with gas throttling of the transfer call, and the storage read in receive being too expensive for unoptimized code.

Solidity automation moved this from Triage to Done Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Solidity
  
Done
Development

No branches or pull requests

1 participant