solidity icon indicating copy to clipboard operation
solidity copied to clipboard

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

Open Subway2023 opened this issue 5 months ago • 0 comments

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.

Subway2023 avatar Sep 04 '24 16:09 Subway2023