Skip to content

IR-based Codegen error: too deep inside the stack. #15405

Closed as not planned
Closed as not planned
@Subway2023

Description

@Subway2023

Environment

  • Compiler version: 0.8.27
  • Target EVM version (as per compiler settings): None
  • Framework/IDE (e.g. Truffle or Remix): None
  • EVM execution environment / backend / blockchain client: None
  • Operating system: Linux

Steps to Reproduce

pragma solidity ^0.8.0;
contract C {
    struct S { uint x; }
    uint[] storageArray;
    bytes memoryArray;
    function g(uint x) public {
        for (uint i = 0; i < x; ++i) {
            storageArray.push(i);
        }
    }
    function f(uint a) public returns (uint, uint) {
        if (a > 1) {
            g(a);
            assembly {
                let temp := sload(storageArray.slot)
                sstore(temp, msize())
            }
        }
        memoryArray = abi.encode(storageArray);
        return (storageArray.length, storageArray[0]);
    }
}
solc --via-ir --bin test.sol
Uncaught exception:
/solidity/libyul/backends/evm/EVMObjectCompiler.cpp(125): Throw in function void solidity::yul::EVMObjectCompiler::run(const solidity::yul::Object&, bool)
Dynamic exception type: boost::wrapexcept<solidity::yul::StackTooDeepError>
std::exception::what: Variable var__38 is 11 slot(s) too deep inside the stack. Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables.
[solidity::util::tag_comment*] = Variable var__38 is 11 slot(s) too deep inside the stack. Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions