argotorg / argotorg/solidity

"Variable dataEnd is 4 slot(s) too deep inside the stack" in an external function returning triple-nested dynamic array

Open
#9,979 6 comments 0 reactions 0 assignees View on GitHub
bug :bug: should compile without error
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
21

Description

## Steps to Reproduce
```solidity
pragma experimental ABIEncoderV2;

contract A {
function get() public view returns (uint[][][] memory) {}

function foo() public view {
A(0x00).get();
}
}
```

It happens only when using the optimizer
```bash
solc --optimize test.sol
```
```
Compiler error: Stack too deep when compiling inline assembly: Variable dataEnd is 4 slot(s) too deep inside the stack.
```
Without the optimizer it compiles just fine.

Running it as a soltest test case gives a bit more info about where the exception is raised:
```
Running 1 test case...
/solidity/test/boostTest.cpp(123): error: in "syntaxTests/test": Exception during extracted test: /solidity/libyul/backends/evm/AsmCodeGen.cpp(248): Throw in function static void solidity::yul::CodeGenerator::assemble(const solidity::yul::Block&, solidity::yul::AsmAnalysisInfo&, solidity::evmasm::Assembly&, solidity::langutil::EVMVersion, const solidity::yul::ExternalIdentifierAccess&, bool, bool)
Dynamic exception type: boost::wrapexcept
std::exception::what: Stack too deep when compiling inline assembly: Variable dataEnd is 4 slot(s) too deep inside the stack.
[solidity::util::tag_comment*] = Stack too deep when compiling inline assembly: Variable dataEnd is 4 slot(s) too deep inside the stack.

*** 1 failure is detected in the test module "SolidityTests"
```

## Environment
- Compiler version: 0.7.3-develop.2020.10.7+commit.d15360a9.Linux.g++

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the contract in test.sol using solc --optimize, then start at libyul/backends/evm/AsmCodeGen.cpp:248 where the StackTooDeepError is raised. The soltest path in test/boostTest.cpp:123 provides additional context. Done means this triple-nested dynamic-array call compiles with the optimizer enabled without the stack-too-deep error.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.