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

Stack too deep yul exception with --via-ir #14990

Open
alex1448 opened this issue Apr 5, 2024 · 1 comment
Open

Stack too deep yul exception with --via-ir #14990

alex1448 opened this issue Apr 5, 2024 · 1 comment
Labels

Comments

@alex1448
Copy link

alex1448 commented Apr 5, 2024

Description

The following code triggers the exception shown bellow. I could not reduce it any further. Any change seems to make the error go away, for example changing the array lengths. I think the "stack too deep" problem is already known, but because this seems to have been working fine up to version 0.8.21, I thought to open a new issue.

Steps to Reproduce

testcase.sol

// SPDX-License-Identifier: GPL-3.0

pragma solidity =0.8.25;

contract C {
    bool b;

    function f() internal pure returns (function () internal view returns (int8[2][][3] memory)) {
    }

    function g() external payable {
        int[5] memory v1;
        int[][1][1] memory v2;
        function () external returns (int8[2][][3][1] memory) v3;

        b ? f()() : v3()[0];
        v2[0] = [new int[](1)];
        new int[](3);
    }
}
solc --asm --optimize --via-ir testcase.sol
Uncaught exception:
./libyul/backends/evm/EVMObjectCompiler.cpp(106): Throw in function void solidity::yul::EVMObjectCompiler::run(solidity::yul::Object&, bool)
Dynamic exception type: boost::wrapexcept<solidity::yul::StackTooDeepError>
std::exception::what: Cannot swap Variable _2 with Variable dst: too deep in the stack by 1 slots in [ JUNK _2 _3 memPtr src _7 _5 _5 memPtr_3 src_1 _8 innerOffset dst_1 memPtr_4 src_2 _9 innerOffset_1 dst_2 dst ]
memoryguard was present.
[solidity::util::tag_comment*] = Cannot swap Variable _2 with Variable dst: too deep in the stack by 1 slots in [ JUNK _2 _3 memPtr src _7 _5 _5 memPtr_3 src_1 _8 innerOffset dst_1 memPtr_4 src_2 _9 innerOffset_1 dst_2 dst ]
memoryguard was present.

Environment

  • Compiler version: >=0.8.22
@Ruko97
Copy link
Contributor

Ruko97 commented Apr 7, 2024

This seems to be similar to #14878

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

No branches or pull requests

2 participants