argotorg / argotorg/solidity

StackTooDeep in EVMObjectCompiler

Open
#15,649 0 comments 0 reactions 0 assignees View on GitHub
bug :bug:
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

Description

## Description

Reproducible test program
```solidity
contract contract0 {
struct struct1 {
bool var2;
}

int16 internal var3;

function func4(int16 var5) internal returns (mapping(int16 => int16[]) storage mapping6, struct1 memory struct_instance10) {
mapping6 = mapping6;
struct_instance10 = struct_instance10;
(bool(false) ? var3 : (var3));
}

function func11(mapping(int16 => int16)[] storage array12) internal view returns (int16 var16) {
struct1 memory struct_instance17;
struct_instance17 = struct_instance17;
if (struct_instance17.var2 && (false)) {} else {
(var3) % (var3);
}
}
}

contract contract18 {
error error19();

error error20(int16 var21);

struct struct22 {
int256[][4] array23;
contract0.struct1 struct_instance26;
}

bool internal var27;

constructor(contract18.struct22[2] memory array28) {
contract18.struct22 memory struct_instance38;
struct_instance38 = struct_instance38;
contract0.struct1 memory struct_instance39;
struct_instance39 = struct_instance39;
true ? struct_instance39 : (struct_instance38.struct_instance26);
}

function func30(mapping(string => struct22) storage mapping31) internal returns (contract0 contract_instance34, contract0.struct1 memory struct_instance35) {
struct_instance35 = struct_instance35;
(this.func36());
}

function func36() external returns (struct22 memory struct_instance37) {
struct_instance37 = struct_instance37;
contract0.struct1 memory struct_instance40;
struct_instance40 = struct_instance40;
contract18.struct22 memory struct_instance41;
struct_instance41 = struct_instance41;
for (; struct_instance40.var2 || var27; var27 ? (struct_instance40) : (struct_instance41.struct_instance26)) {
var27 ? true : struct_instance41.struct_instance26.var2;
}
return (this.func36());
}
}
```

Compilation command:
```
../AFLs/new-solidity/build/solc/solc generated_programs/program_2024-12-17_17:35:8_27.sol --asm --yul-optimizations oEDVnxapifleursthCOScIMjLFUg --optimize-runs 6 --optimize-yul --model-checker-ext-calls untrusted --via-ir
```

Error message:
```
Uncaught exception:
/solidity/libyul/backends/evm/EVMObjectCompiler.cpp(106): Throw in function run
Dynamic exception type: boost::wrapexcept
std::exception::what: Variable length is 1 too deep in the stack [ _1 length array_2 memoryDataOffset size_1 src offset dst value_1 innerOffset array_5 offset_1 src_1 size_3 array_8 dst_2 elementPos dst_1 ]
memoryguard was present.
[solidity::util::tag_comment*] = Variable length is 1 too deep in the stack [ _1 length array_2 memoryDataOffset size_1 src offset dst value_1 innerOffset array_5 offset_1 src_1 size_3 array_8 dst_2 elementPos dst_1 ]
memoryguard was present.
```

## Environment

- Compiler version:0.8.29-develop.2024.11.30+commit.b4ecc58b.Linux.g++

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the provided Solidity program and solc command, then inspect solidity/libyul/backends/evm/EVMObjectCompiler.cpp around line 106. Trace the StackTooDeepError and memoryguard report; done means this input no longer fails with the uncaught exception or the issue has a documented, reproducible outcome.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.